Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into enh/plotting_impr…
Browse files Browse the repository at this point in the history
…ovements
  • Loading branch information
effigies committed Jan 22, 2019
2 parents a7fa17d + 890f48d commit 0bc7995
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ USER neuro
# Update conda environment
#-------------------------
RUN /bin/bash -c "source activate neuro \
&& pip install -q --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir --upgrade 'pip<19' \
&& pip install -q --no-cache-dir --upgrade -r /src/fitlins/requirements.txt" \
&& sync

Expand Down
4 changes: 2 additions & 2 deletions fitlins/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
'pandas>=0.19',
'tables>=3.2.1',
'nistats>=0.0.1b0',
'pybids>=0.6.5',
'pybids>=0.7',
'jinja2',
]

LINKS_REQUIRES = [
'git+https://github.com/bids-standard/pybids.git@'
'36853b0bf222d3174ae7d9d1d9c7a7ecf5049cdd#egg=pybids',
'a4bbc811e67df8ffbc186cca4c3c61e0992af09f#egg=pybids',
]

TESTS_REQUIRES = [
Expand Down
19 changes: 15 additions & 4 deletions fitlins/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ def get_parser():
g_bids.add_argument('--derivative-label', action='store', type=str,
help='execution label to append to derivative directory name')
g_bids.add_argument('--space', action='store',
choices=['MNI152NLin2009cAsym'], default='MNI152NLin2009cAsym',
help='registered space of input datasets')
choices=['MNI152NLin2009cAsym', ''],
default='MNI152NLin2009cAsym',
help='registered space of input datasets. Empty value for no explicit space.')
g_bids.add_argument('--include', action='store', default=None,
help='regex pattern to include files')
g_bids.add_argument('--exclude', action='store', default=None,
help='regex pattern to exclude files')
g_bids.add_argument('--desc-label', action='store', default='preproc',
help="use BOLD files with the provided description label")

g_perfm = parser.add_argument_group('Options to handle performance')
g_perfm.add_argument('--n-cpus', action='store', default=0, type=int,
Expand All @@ -110,6 +113,9 @@ def run_fitlins(argv=None):
opts = get_parser().parse_args(argv)
if opts.debug:
logger.setLevel(logging.DEBUG)
if not opts.space:
# make it an explicit None
opts.space = None

subject_list = None
if opts.participant_label is not None:
Expand Down Expand Up @@ -141,7 +147,10 @@ def run_fitlins(argv=None):

derivatives = True if not opts.derivatives else opts.derivatives
# Need this when specifying args directly (i.e. neuroscout)
if len(derivatives) == 1:
# god bless neuroscout, but let's make it work for others!
if isinstance(derivatives, list) and len(derivatives) == 1:
# WRONG AND EVIL to those who have spaces in their paths... bad bad practice
# TODO - fix neuroscout
derivatives = derivatives[0].split(" ")

pipeline_name = 'fitlins'
Expand All @@ -155,7 +164,9 @@ def run_fitlins(argv=None):
work_dir = mkdtemp() if opts.work_dir is None else opts.work_dir

fitlins_wf = init_fitlins_wf(
opts.bids_dir, derivatives, deriv_dir, opts.space, model=model,
opts.bids_dir, derivatives, deriv_dir, opts.space,
desc=opts.desc_label,
model=model,
participants=subject_list, base_dir=work_dir,
include_pattern=opts.include, exclude_pattern=opts.exclude
)
Expand Down
20 changes: 13 additions & 7 deletions fitlins/interfaces/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,19 @@ def _load_level1(self, runtime, analysis):
# ents is now pretty populous
ents.pop('suffix', None)
ents.pop('datatype', None)
if 'space' in ents:
# Guaranteed to be valid
space = ents.pop('space')
else:
# Picks first match
space = analysis.layout.get_spaces(suffix='bold',
extensions=['.nii', '.nii.gz'])[0]
space = ents.pop('space', None)
if space is None:
spaces = analysis.layout.get_spaces(
suffix='bold',
extensions=['.nii', '.nii.gz'])
if spaces:
spaces = sorted(spaces)
space = spaces[0]
if len(spaces) > 1:
iflogger.warning(
'No space was provided, but multiple spaces were detected: %s. '
'Selecting the first (ordered lexicographically): %s'
% (', '.join(spaces), space))
preproc_files = analysis.layout.get(suffix='bold',
extensions=['.nii', '.nii.gz'],
space=space,
Expand Down
9 changes: 6 additions & 3 deletions fitlins/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
from ..interfaces.utils import MergeAll


def init_fitlins_wf(bids_dir, derivatives, out_dir, space, exclude_pattern=None,
include_pattern=None, model=None, participants=None,
def init_fitlins_wf(bids_dir, derivatives, out_dir, space, desc=None,
exclude_pattern=None, include_pattern=None,
model=None, participants=None,
base_dir=None, name='fitlins_wf'):
wf = pe.Workflow(name=name, base_dir=base_dir)

Expand Down Expand Up @@ -48,7 +49,9 @@ def init_fitlins_wf(bids_dir, derivatives, out_dir, space, exclude_pattern=None,
BIDSSelect(
bids_dir=bids_dir, derivatives=derivatives,
selectors={
'type': 'preproc', 'suffix': 'bold', 'space': space}),
'suffix': 'bold',
'desc': desc,
'space': space}),
name='getter')

l1_model = pe.MapNode(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ nilearn>=0.4.0
pandas>=0.19
nipype>=1.1.6
git+https://github.com/nistats/nistats.git@009ce3fddb3dd01e82bca3ad7d2cdbeece0138f2#egg=nistats
git+https://github.com/bids-standard/pybids.git@36853b0bf222d3174ae7d9d1d9c7a7ecf5049cdd#egg=pybids
git+https://github.com/bids-standard/pybids.git@a4bbc811e67df8ffbc186cca4c3c61e0992af09f#egg=pybids

0 comments on commit 0bc7995

Please sign in to comment.