Skip to content

Commit 1e16f08

Browse files
authored
Merge pull request #608 from dbic/bf-docs
DOC: Various fixes to make RTD build the docs again
2 parents 4ac084b + f78290b commit 1e16f08

File tree

10 files changed

+77
-92
lines changed

10 files changed

+77
-92
lines changed

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ python:
88
build:
99
os: ubuntu-20.04
1010
tools:
11-
python: "3"
11+
python: "3.9"
1212
sphinx:
1313
configuration: docs/conf.py
1414
fail_on_warning: true

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Please file issues and suggest changes via Pull Requests.
5454

5555
HeuDiConv requires installation of
5656
`dcm2niix <https://github.com/rordenlab/dcm2niix/>`_ and optionally
57-
`DataLad <https://datalad.org>`_.
57+
`DataLad`_.
5858

5959
For development you will need a non-shallow clone (so there is a
6060
recent released tag) of the aforementioned repository. You can then

docs/changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Changes
33
=======
44

5-
.. mdinclude:: ../CHANGELOG.md
5+
.. literalinclude:: ../CHANGELOG.md

docs/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from heudiconv import __version__
2323

2424
project = 'heudiconv'
25-
copyright = '2019, Heudiconv team'
25+
copyright = '2014-2022, Heudiconv team'
2626
author = 'Heudiconv team'
2727

2828
# The short X.Y version
@@ -43,7 +43,7 @@
4343
extensions = [
4444
'sphinx.ext.autodoc',
4545
'sphinxarg.ext',
46-
'm2r',
46+
'sphinx.ext.napoleon',
4747
]
4848

4949
# Add any paths that contain templates here, relative to this directory.
@@ -63,7 +63,7 @@
6363
#
6464
# This is also used if you do content translation via gettext catalogs.
6565
# Usually you set "language" from the command line for these cases.
66-
language = None
66+
language = 'en'
6767

6868
# List of patterns, relative to source directory, that match files and
6969
# directories to ignore when looking for source files.
@@ -90,7 +90,7 @@
9090
# Add any paths that contain custom static files (such as style sheets) here,
9191
# relative to this directory. They are copied after the builtin static files,
9292
# so a file named "default.css" will overwrite the builtin "default.css".
93-
html_static_path = ['_static']
93+
html_static_path = []
9494

9595
# Custom sidebar templates, must be a dictionary that maps document names
9696
# to template names.

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
sphinx-argparse
2-
m2r
2+
sphinxcontrib-napoleon
33
-r ../dev-requirements.txt

heudiconv/bids.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Handle BIDS specific operations"""
22

3+
__docformat__ = "numpy"
4+
35
import hashlib
46
import os
57
import os.path as op
@@ -157,12 +159,12 @@ def populate_bids_templates(path, defaults={}):
157159

158160

159161
def populate_aggregated_jsons(path):
160-
"""Aggregate across the entire BIDS dataset .json's into top level .json's
162+
"""Aggregate across the entire BIDS dataset ``.json``\s into top level ``.json``\s
161163
162164
Top level .json files would contain only the fields which are
163-
common to all subject[/session]/type/*_modality.json's.
165+
common to all ``subject[/session]/type/*_modality.json``\s.
164166
165-
ATM aggregating only for *_task*_bold.json files. Only the task- and
167+
ATM aggregating only for ``*_task*_bold.json`` files. Only the task- and
166168
OPTIONAL _acq- field is retained within the aggregated filename. The other
167169
BIDS _key-value pairs are "aggregated over".
168170
@@ -415,15 +417,14 @@ def save_scans_key(item, bids_files):
415417

416418

417419
def add_rows_to_scans_keys_file(fn, newrows):
418-
"""
419-
Add new rows to file fn for scans key filename and generate accompanying json
420-
descriptor to make BIDS validator happy.
420+
"""Add new rows to the _scans file.
421421
422422
Parameters
423423
----------
424-
fn: filename
425-
newrows: extra rows to add
426-
dict fn: [acquisition time, referring physician, random string]
424+
fn: str
425+
filename
426+
newrows: dict
427+
extra rows to add (acquisition time, referring physician, random string)
427428
"""
428429
if op.lexists(fn):
429430
with open(fn, 'r') as csvfile:
@@ -527,11 +528,11 @@ def get_shim_setting(json_file):
527528
Gets the "ShimSetting" field from a json_file.
528529
If no "ShimSetting" present, return error
529530
530-
Parameters:
531+
Parameters
531532
----------
532533
json_file : str
533534
534-
Returns:
535+
Returns
535536
-------
536537
str with "ShimSetting" value
537538
"""
@@ -552,13 +553,13 @@ def find_fmap_groups(fmap_dir):
552553
By groups here we mean fmaps that are intended to go together
553554
(with reversed PE polarity, magnitude/phase, etc.)
554555
555-
Parameters:
556+
Parameters
556557
----------
557558
fmap_dir : str or os.path
558559
path to the session folder (or to the subject folder, if there are no
559560
sessions).
560561
561-
Returns:
562+
Returns
562563
-------
563564
fmap_groups : dict
564565
key: prefix common to the group (e.g. no "dir" entity, "_phase"/"_magnitude", ...)
@@ -598,14 +599,14 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter):
598599
(Note: It is the responsibility of the calling function to make sure
599600
the arguments are OK)
600601
601-
Parameters:
602+
Parameters
602603
----------
603604
json_file : str or os.path
604605
path to the json file
605606
matching_parameter : str in AllowedFmapParameterMatching
606607
matching_parameter that will be used to match runs
607608
608-
Returns:
609+
Returns
609610
-------
610611
key_info : dict
611612
part of the json file that will need to match between the fmap and
@@ -666,7 +667,7 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters):
666667
(Note: It is the responsibility of the calling function to make sure
667668
the arguments are OK)
668669
669-
Parameters:
670+
Parameters
670671
----------
671672
json_file : str or os.path
672673
path to the json file
@@ -676,7 +677,7 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters):
676677
matching_parameters : list of str from AllowedFmapParameterMatching
677678
matching_parameters that will be used to match runs
678679
679-
Returns:
680+
Returns
680681
-------
681682
compatible_fmap_groups : dict
682683
Subset of the fmap_groups which match json_file, according
@@ -720,15 +721,15 @@ def find_compatible_fmaps_for_session(path_to_bids_session, matching_parameters)
720721
(Note: It is the responsibility of the calling function to make sure
721722
the arguments are OK)
722723
723-
Parameters:
724+
Parameters
724725
----------
725726
path_to_bids_session : str or os.path
726727
path to the session folder (or to the subject folder, if there are no
727728
sessions).
728729
matching_parameters : list of str from AllowedFmapParameterMatching
729730
matching_parameters that will be used to match runs
730731
731-
Returns:
732+
Returns
732733
-------
733734
compatible_fmap : dict
734735
Dict of compatible_fmaps_groups (values) for each non-fmap run (keys)
@@ -768,7 +769,7 @@ def select_fmap_from_compatible_groups(json_file, compatible_fmap_groups, criter
768769
(Note: It is the responsibility of the calling function to make sure
769770
the arguments are OK)
770771
771-
Parameters:
772+
Parameters
772773
----------
773774
json_file : str or os.path
774775
path to the json file
@@ -777,7 +778,7 @@ def select_fmap_from_compatible_groups(json_file, compatible_fmap_groups, criter
777778
criterion : str in ['First', 'Closest']
778779
matching_parameters that will be used to decide which fmap to use
779780
780-
Returns:
781+
Returns
781782
-------
782783
selected_fmap_key : str or os.path
783784
key from the compatible_fmap_groups for the selected fmap group
@@ -859,7 +860,7 @@ def populate_intended_for(path_to_bids_session, matching_parameters, criterion):
859860
Because fmaps come in groups (with reversed PE polarity, or magnitude/
860861
phase), we work with fmap_groups.
861862
862-
Parameters:
863+
Parameters
863864
----------
864865
path_to_bids_session : str or os.path
865866
path to the session folder (or to the subject folder, if there are no

heudiconv/convert.py

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__docformat__ = "numpy"
2+
13
import filelock
24
import os
35
import os.path as op
@@ -453,23 +455,6 @@ def convert(items, converter, scaninfo_suffix, custom_callable, with_prov,
453455
dcmconfig=None, populate_intended_for_opts={}):
454456
"""Perform actual conversion (calls to converter etc) given info from
455457
heuristic's `infotodict`
456-
457-
Parameters
458-
----------
459-
items
460-
symlink
461-
converter
462-
scaninfo_suffix
463-
custom_callable
464-
with_prov
465-
is_bids
466-
sourcedir
467-
outdir
468-
min_meta
469-
470-
Returns
471-
-------
472-
None
473458
"""
474459
prov_files = []
475460
tempdirs = TempDirs()
@@ -624,10 +609,6 @@ def convert_dicom(item_dicoms, bids_options, prefix,
624609
Create softlink to DICOMs - if False, create hardlink instead.
625610
overwrite : bool
626611
If True, allows overwriting of previous conversion
627-
628-
Returns
629-
-------
630-
None
631612
"""
632613
if bids_options is not None:
633614
# mimic the same hierarchy location as the prefix
@@ -666,18 +647,18 @@ def nipype_convert(item_dicoms, prefix, with_prov, bids_options, tmpdir, dcmconf
666647
667648
Parameters
668649
----------
669-
item_dicoms : List
650+
item_dicoms : list
670651
DICOM files to convert
671-
prefix : String
652+
prefix : str
672653
Heuristic output path
673-
with_prov : Bool
654+
with_prov : bool
674655
Store provenance information
675-
bids_options : List or None
656+
bids_options : list or None
676657
If not None then output BIDS sidecar JSONs
677658
List may contain bids specific options
678-
tmpdir : Directory
659+
tmpdir : str
679660
Conversion working directory
680-
dcmconfig : File (optional)
661+
dcmconfig : str, optional
681662
JSON file used for additional Dcm2niix configuration
682663
"""
683664
import nipype
@@ -723,18 +704,19 @@ def nipype_convert(item_dicoms, prefix, with_prov, bids_options, tmpdir, dcmconf
723704

724705
def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outname_bids, overwrite):
725706
"""Copy converted files from tempdir to output directory.
707+
726708
Will rename files if necessary.
727709
728710
Parameters
729711
----------
730712
res : Node
731713
Nipype conversion Node with results
732-
item_dicoms: list of filenames
733-
DICOMs converted
714+
item_dicoms: list
715+
Filenames of converted DICOMs
734716
bids : list or None
735717
If not list save to BIDS
736718
List may contain bids specific options
737-
prefix : string
719+
prefix : str
738720
739721
Returns
740722
-------
@@ -877,15 +859,13 @@ def save_converted_files(res, item_dicoms, bids_options, outtype, prefix, outnam
877859
return bids_outfiles
878860

879861

880-
def add_taskname_to_infofile(infofiles):
862+
def add_taskname_to_infofile(infofiles):
881863
"""Add the "TaskName" field to json files corresponding to func images.
882864
883865
Parameters
884866
----------
885-
infofiles : list with json filenames or single filename
886-
887-
Returns
888-
-------
867+
infofiles: list or str
868+
json filenames or a single filename.
889869
"""
890870

891871
# in case they pass a string with a path:
@@ -908,15 +888,15 @@ def add_taskname_to_infofile(infofiles):
908888

909889
def bvals_are_zero(bval_file):
910890
"""Checks if all entries in a bvals file are zero (or 5, for Siemens files).
911-
Returns True if that is the case, otherwise returns False
912891
913892
Parameters
914893
----------
915-
bval_file : file with the bvals
894+
bval_file : str
895+
file with the bvals
916896
917897
Returns
918898
-------
919-
True if all are zero; False otherwise.
899+
True if all are all 0 or 5; False otherwise.
920900
"""
921901

922902
with open(bval_file) as f:

heudiconv/parser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
def find_files(regex, topdir=op.curdir, exclude=None,
3030
exclude_vcs=True, dirs=False):
3131
"""Generator to find files matching regex
32+
3233
Parameters
3334
----------
3435
regex: basestring
@@ -60,7 +61,8 @@ def find_files(regex, topdir=op.curdir, exclude=None,
6061

6162

6263
def get_extracted_dicoms(fl):
63-
"""Given a list of files, possibly extract some from tarballs
64+
"""Given a list of files, possibly extract some from tarballs.
65+
6466
For 'classical' heudiconv, if multiple tarballs are provided, they correspond
6567
to different sessions, so here we would group into sessions and return
6668
pairs `sessionid`, `files` with `sessionid` being None if no "sessions"
@@ -116,13 +118,15 @@ def get_extracted_dicoms(fl):
116118

117119
def get_study_sessions(dicom_dir_template, files_opt, heuristic, outdir,
118120
session, sids, grouping='studyUID'):
119-
"""Given options from cmdline sort files or dicom seqinfos into
120-
study_sessions which put together files for a single session of a subject
121-
in a study
122-
Two major possible workflows:
121+
"""Sort files or dicom seqinfos into study_sessions.
122+
123+
study_sessions put together files for a single session of a subject
124+
in a study. Two major possible workflows:
125+
123126
- if dicom_dir_template provided -- doesn't pre-load DICOMs and just
124127
loads files pointed by each subject and possibly sessions as corresponding
125-
to different tarballs
128+
to different tarballs.
129+
126130
- if files_opt is provided, sorts all DICOMs it can find under those paths
127131
"""
128132
study_sessions = {}

0 commit comments

Comments
 (0)