Skip to content

Commit 3598e6d

Browse files
committed
doc: styling, heuristics
1 parent dc44b32 commit 3598e6d

File tree

4 files changed

+98
-96
lines changed

4 files changed

+98
-96
lines changed

docs/heuristics.rst

Lines changed: 71 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,71 @@
1-
## The heuristic file
2-
3-
The heuristic file controls how information about the dicoms is used to convert
4-
to a file system layout (e.g., BIDS). This is a python file that must have the
5-
function `infotodict`, which takes a single argument `seqinfo`.
6-
7-
### `seqinfo` and the `s` variable
8-
9-
`seqinfo` is a list of namedtuple objects, each containing the following fields:
10-
11-
* total_files_till_now
12-
* example_dcm_file
13-
* series_id
14-
* dcm_dir_name
15-
* unspecified2
16-
* unspecified3
17-
* dim1
18-
* dim2
19-
* dim3
20-
* dim4
21-
* TR
22-
* TE
23-
* protocol_name
24-
* is_motion_corrected
25-
* is_derived
26-
* patient_id
27-
* study_description
28-
* referring_physician_name
29-
* series_description
30-
* image_type
31-
32-
```
33-
128 125000-1-1.dcm 1 - -
34-
- 160 160 128 1 0.00315 1.37 AAHScout False
35-
```
36-
37-
### The dictionary returned by `infotodict`
38-
39-
This dictionary contains as keys a 3-tuple `(template, a tuple of output types,
40-
annotation classes)`.
41-
42-
template - how the file should be relative to the base directory
43-
tuple of output types - what format of output should be created - nii.gz, dicom,
44-
etc.,.
45-
annotation classes - unused
46-
47-
```
48-
Example: ('func/sub-{subject}_task-face_run-{item:02d}_acq-PA_bold', ('nii.gz',
49-
'dicom'), None)
50-
```
51-
52-
A few fields are defined by default and can be used in the template:
53-
54-
- item: index within category
55-
- subject: participant id
56-
- seqitem: run number during scanning
57-
- subindex: sub index within group
58-
- session: session info for multi-session studies and when session has been
59-
defined as a parameter for heudiconv
60-
61-
Additional variables may be added and can be returned in the value of the
62-
dictionary returned from the function.
63-
64-
`info[some_3-tuple] = [12, 14, 16]` would assign dicom sequence groups 12, 14
65-
and 16 to be converted using the template specified in `some_3-tuple`.
66-
67-
if the template contained a non-sanctioned variable, it would have to be
68-
provided in the values for that key.
69-
70-
```
71-
some_3_tuple = ('func/sub-{subject}_task-face_run-{item:02d}_acq-{acq}_bold', ('nii.gz',
72-
'dicom'), None)
73-
```
74-
75-
In the above example `{acq}` is not a standard variable. In this case, values
76-
for this variable needs to be added.
77-
78-
```
79-
info[some_3-tuple] = [{'item': 12, 'acq': 'AP'},
80-
{'item': 14, 'acq': 'AP'},
81-
{'item': 16, 'acq': 'PA'}]
82-
```
1+
=========
2+
Heuristic
3+
=========
4+
5+
The heuristic file controls how information about the DICOMs is used to convert
6+
to a file system layout (e.g., BIDS). ``heudiconv`` includes some built-in
7+
heuristics, including `ReproIn <https://github.com/ReproNim/reproin/blob/master/README.md>`_
8+
(which is great to adopt if you will be starting your data collection!).
9+
10+
However, there is a large variety of data out there, and not all DICOMs will be
11+
covered by the existing heuristics. This section will outline what makes up a
12+
heuristic file, and some useful functions available when making one.
13+
14+
15+
Components
16+
==========
17+
18+
---------------------
19+
`infotodict(seqinfos)`
20+
---------------------
21+
22+
The only required function for a heuristic, `infotodict` is used to both define
23+
the conversion outputs and specify the criteria for scan to output association.
24+
Conversion outputs are defined as keys, a `tuple` consisting of a template path
25+
used for the basis of outputs, as well as a `tuple` of output types. Valid types
26+
include `nii`, `nii.gz`, and `dicom`.
27+
28+
.. note::
29+
30+
An example conversion key:
31+
('sub-{subject}/func/sub-{subject}_task-test_run-{item}_bold', ('nii.gz', 'dicom'))
32+
33+
34+
The `seqinfos` parameter is a list of namedtuples which serves as a grouped and
35+
stacked record of the DICOMs passed in. Each item in `seqinfo` contains DICOM
36+
metadata that can be used to isolate the series, and assign it to a conversion
37+
key.
38+
39+
A dictionary of {conversion key: seqinfo} is returned.
40+
41+
-------------------------------
42+
`create_key(template, outtype)`
43+
-------------------------------
44+
45+
A common helper function used to create the conversion key in `infotodict`.
46+
47+
------------------
48+
`filter_files(fl)`
49+
------------------
50+
51+
A utility function used to filter any input files.
52+
53+
If this function is included, every file found will go through this filter. Any
54+
files where this function returns `True` will be filtered out.
55+
56+
------------------------
57+
`filter_dicom(dcm_data)`
58+
------------------------
59+
60+
A utility function used to filter any DICOMs.
61+
62+
If this function is included, every DICOM found will go through this filter. Any
63+
DICOMs where this function returns `True` will be filtered out.
64+
65+
----------------------------
66+
`infotoids(seqinfos, outdir)`
67+
----------------------------
68+
69+
Further processing on `seqinfos` to deduce/customize subject, session, and locator.
70+
71+
A dictionary of {"locator": locator, "session": session, "subject": subject} is returned.

docs/index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Contents
99
--------
1010

1111
.. toctree::
12-
:maxdepth: 1
13-
12+
:maxdepth: 2
13+
1414
installation
15-
../CHANGELOG.md
15+
../CHANGELOG
1616
usage
1717
heuristics
1818
tutorials
19-
reference
19+
API

docs/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
1+
============
22
Installation
3-
------------
3+
============
44

55
``Heudiconv`` is packaged and available from many different sources.
66

77

88
Local
9-
-----
9+
=====
1010
Released versions of HeuDiConv are available on `PyPI <https://pypi.org/project/heudiconv/>`_
1111
and `conda <https://github.com/conda-forge/heudiconv-feedstock#installing-heudiconv>`_.
1212
If installing through ``PyPI``, eg::
@@ -21,7 +21,7 @@ Manual installation of `dcm2niix <https://github.com/rordenlab/dcm2niix#install>
2121

2222

2323
Docker
24-
------
24+
======
2525
If `Docker <https://docs.docker.com/install/>`_ is available on your system, you
2626
can visit `our page on Docker Hub <https://hub.docker.com/r/nipy/heudiconv/tags>`_
2727
to view available releases. To pull the latest release, run::
@@ -30,7 +30,7 @@ If `Docker <https://docs.docker.com/install/>`_ is available on your system, you
3030

3131

3232
Singularity
33-
-----------
33+
===========
3434
If `Singularity <https://www.sylabs.io/singularity/>`_ is available on your system,
3535
you can use it to pull and convert our Docker images! For example, to pull and
3636
build the latest release, you can run::

docs/tutorials.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1+
==============
2+
User Tutorials
3+
==============
4+
15
Luckily(?), we live in an era of plentiful information. Below are some links to
26
other users' tutorials covering their experience with ``heudiconv``.
37

4-
- `YouTube tutorial <https://www.youtube.com/watch?v=O1kZAuR7E00>`_ by `James Kent <https://github.com/jdkent>`_.
5-
- `Walkthrough <http://reproducibility.stanford.edu/bids-tutorial-series-part-2a/>`_ by the `Standard Center for Reproducible Neuroscience <http://reproducibility.stanford.edu/>`_.
6-
- `Sample Conversion: Coastal Coding 2019 <http://www.repronim.org/coco2019-training/presentations/heudiconv/#1>`_.
7-
- `U of A Neuroimaging Core <https://neuroimaging-core-docs.readthedocs.io/en/latest/pages/heudiconv.html>`_ by `Dianne Patterson <https://github.com/dkp>`_.
8+
- `YouTube tutorial <https://www.youtube.com/watch?v=O1kZAuR7E00>`_ by
9+
`James Kent <https://github.com/jdkent>`_.
10+
11+
- `Walkthrough <http://reproducibility.stanford.edu/bids-tutorial-series-part-2a/>`_
12+
by the `Standard Center for Reproducible Neuroscience <http://reproducibility.stanford.edu/>`_.
13+
14+
- `U of A Neuroimaging Core <https://neuroimaging-core-docs.readthedocs.io/en/latest/pages/heudiconv.html>`_
15+
by `Dianne Patterson <https://github.com/dkp>`_.
16+
17+
- `Sample Conversion: Coastal Coding 2019 <http://www.repronim.org/coco2019-training/presentations/heudiconv/#1>`_.
18+
19+
.. note::
820

9-
** Note: some of these tutorials may not be 100% up to date with the latest releases of ``heudiconv``, so refer to this documentation first.
21+
Keep in mind, some of these tutorials may not be 100% up to date with
22+
the latest releases of ``heudiconv``.

0 commit comments

Comments
 (0)