-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from asmacdo/add-dianne-tutorials
Add dianne tutorials
- Loading branch information
Showing
12 changed files
with
667 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
============= | ||
CLI Reference | ||
============= | ||
|
||
``heudiconv`` processes DICOM files and converts the output into user defined | ||
paths. | ||
|
||
.. argparse:: | ||
:ref: heudiconv.cli.run.get_parser | ||
:prog: heudiconv | ||
:nodefault: | ||
:nodefaultconst: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
============================== | ||
Using heudiconv in a Container | ||
============================== | ||
|
||
If heudiconv is :ref:`installed via a Docker container <install_container>`, you | ||
can run the commands in the following format:: | ||
docker run nipy/heudiconv:latest [heudiconv options] | ||
|
||
So a user running via container would check the version with this command:: | ||
|
||
docker run nipy/heudiconv:latest --version | ||
|
||
Which is equivalent to the locally installed command:: | ||
|
||
heudiconv --version | ||
|
||
Bind mount | ||
---------- | ||
|
||
Typically, users of heudiconv will be operating on data that is on their local machine. We can give heudiconv access to that data via a ``bind mount``, which is the ``-v`` syntax. | ||
|
||
Once common pattern is to share the working directory with ``-v $PWD:$PWD``, so heudiconv will behave as though it is installed on your system. However, you should be aware of how permissions work depending on your container toolset. | ||
|
||
|
||
Docker Permissions | ||
****************** | ||
|
||
When you run a container with docker without specifying a user, it will be run as root. | ||
This isn't ideal if you are operating on data owned by your local user, so for ``Docker`` it is recommended to specify that the container will run as your user.:: | ||
|
||
docker run --user=$(id -u):$(id -g) -e "UID=$(id -u)" -e "GID=$(id -g)" --rm -t -v $PWD:$PWD nipy/heudiconv:latest --version | ||
|
||
Podman Permissions | ||
****************** | ||
|
||
When running Podman without specifying a user, the container is run as root inside the container, but your user outside of the container. | ||
This default behavior usually works for heudiconv users:: | ||
|
||
docker run -v $PWD:PWD nipy/heudiconv:latest --version | ||
|
||
Other Common Options | ||
-------------------- | ||
|
||
We typically recommend users make use of the following flags to Docker and Podman | ||
|
||
* ``-it`` Interactive terminal | ||
* ``--rm`` Remove the changes to the container when it completes | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,9 @@ Contents | |
|
||
installation | ||
changes | ||
usage | ||
heuristics | ||
tutorials | ||
heuristics | ||
commandline | ||
container | ||
api | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
Quickstart | ||
========== | ||
|
||
This tutorial is based on `Dianne Patterson's University of Arizona tutorials <https://neuroimaging-core-docs.readthedocs.io/en/latest/pages/heudiconv.html#lesson-3-reproin-py>`_ | ||
|
||
This guide assumes you have already :ref:`installed heudiconv and dcm2niix <install_local>` and | ||
demonstrates how to use the heudiconv tool with a provided `heuristic.py` to convert DICOMS into the BIDS data structure. | ||
|
||
.. _prepare_dataset: | ||
|
||
Prepare Dataset | ||
*************** | ||
|
||
Download and unzip `sub-219_dicom.zip <https://datasets.datalad.org/?dir=/repronim/heudiconv-tutorial-example/>`_. | ||
|
||
We will be working from a directory called MRIS. Under the MRIS directory is the *dicom* subdirectory: Under the subject number *219* the session *itbs* is nested. Each dicom sequence folder is nested under the session:: | ||
|
||
dicom | ||
└── 219 | ||
└── itbs | ||
├── Bzero_verify_PA_17 | ||
├── DTI_30_DIRs_AP_15 | ||
├── Localizers_1 | ||
├── MoCoSeries_19 | ||
├── MoCoSeries_31 | ||
├── Post_TMS_restingstate_30 | ||
├── T1_mprage_1mm_13 | ||
├── field_mapping_20 | ||
├── field_mapping_21 | ||
└── restingstate_18 | ||
Nifti | ||
└── code | ||
└── heuristic1.py | ||
|
||
Basic Conversion | ||
**************** | ||
|
||
Next we will use heudiconv convert DICOMS into the BIDS data structure. | ||
The example dataset includes an example heuristic file, `heuristic1.py`. | ||
Typical use of heudiconv will require the creation and editing of your :doc:`heuristics file <heuristics>`, which we will cover | ||
in a :doc:`later tutorial <custom-heuristic>`. | ||
|
||
.. note:: Heudiconv requires you to run the command from the parent | ||
directory of both the Dicom and Nifti directories, which is `MRIS` in | ||
our case. | ||
|
||
Run the following command:: | ||
|
||
heudiconv --files dicom/219/itbs/*/*.dcm -o Nifti -f Nifti/code/heuristic1.py -s 219 -ss itbs -c dcm2niix -b --minmeta --overwrite | ||
|
||
|
||
* We specify the dicom files to convert with `--files` | ||
* The heuristic file is provided with the `-f` option | ||
* We tell heudiconv to place our output in the Nifti dir with `-o` | ||
* `-b` indicates that we want to output in BIDS format | ||
* `--minmeta` guarantees that meta-information in the dcms does not get inserted into the JSON sidecar. This is good because the information is not needed but can overflow the JSON file causing some BIDS apps to crash. | ||
|
||
Output | ||
****** | ||
|
||
The *Nifti* directory will contain a bids-compliant subject directory:: | ||
└── sub-219 | ||
└── ses-itbs | ||
├── anat | ||
├── dwi | ||
├── fmap | ||
└── func | ||
The following required BIDS text files are also created in the Nifti directory. Details for filling in these skeleton text files can be found under `tabular files <https://bids-specification.readthedocs.io/en/stable/02-common-principles.html#tabular-files>`_ in the BIDS specification:: | ||
CHANGES | ||
README | ||
dataset_description.json | ||
participants.json | ||
participants.tsv | ||
task-rest_bold.json | ||
Validation | ||
********** | ||
|
||
Ensure that everything is according to spec by using `bids validator <https://bids-standard.github.io/bids-validator/>`_ | ||
|
||
Click `Choose File` and then select the *Nifti* directory. There should be no errors (though there are a couple of warnings). | ||
|
||
.. Note:: Your files are not uploaded to the BIDS validator, so there are no privacy concerns! | ||
|
||
Next | ||
**** | ||
|
||
In the following sections, you will modify *heuristic.py* yourself so you can test different options and understand how to work with your own data. |
Oops, something went wrong.