Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyAFQ pipeline: Use previous analysis derivatives as inputs for masks: seed and brain. #571

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions qsiprep/data/pipelines/pyafq_tractometry.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"directions": "prob",
"max_angle": 30.0,
"sphere": "",
"seed_mask": "",
"seed_threshold": 0,
"seed_mask": "WM_probseg",
"seed_threshold": 0.5,
"n_seeds": 1,
"random_seeds": false,
"rng_seed": "",
"stop_mask": "",
"stop_threshold": 0,
"stop_mask": "WM_probseg",
"stop_threshold": 0.5,
"step_size": 0.5,
"min_length": 50,
"max_length": 250,
Expand Down Expand Up @@ -67,7 +67,6 @@
"csd_lambda_": 1,
"csd_tau": 0.1,
"gtol": 0.01,
"brain_mask_definition": "",
"bundle_info": "",
"reg_template_spec": "mni_T1",
"mapping_definition": "",
Expand Down
25 changes: 20 additions & 5 deletions qsiprep/interfaces/pyafq.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PyAFQInputSpec(BaseInterfaceInputSpec):
bvec_file = File(exists=True, mandatory=True)
dwi_file = File(exists=True, mandatory=True)
mask_file = File(exists=True, mandatory=True)
wm_mask_file = File(exists=True, mandatory=True)
itk_file = File(exists=True, mandatory=True)
kwargs = traits.Dict(exists=True, mandatory=True)
tck_file = traits.Either(None, File(exists=True))
Expand All @@ -56,31 +57,44 @@ def _run_interface(self, runtime):
newpath=shim_dir)
mask_file = fname_presuffix(self.inputs.mask_file,
newpath=shim_dir)
wm_mask_file = fname_presuffix(self.inputs.wm_mask_file,
newpath=shim_dir)
itk_file = fname_presuffix(self.inputs.itk_file,
newpath=shim_dir)
os.symlink(self.inputs.bval_file, bval_file)
os.symlink(self.inputs.bvec_file, bvec_file)
os.symlink(self.inputs.dwi_file, dwi_file)
os.symlink(self.inputs.mask_file, mask_file)
os.symlink(self.inputs.itk_file, itk_file)

os.symlink(self.inputs.wm_mask_file, wm_mask_file)
kwargs = self.inputs.kwargs

if self.inputs.tck_file and isdefined(self.inputs.tck_file):
tck_file = fname_presuffix(self.inputs.tck_file,
newpath=shim_dir)
newpath=shim_dir)
os.symlink(self.inputs.tck_file, tck_file)
else:
tck_file = None

brain_mask_definition = ImageFile(path=mask_file)
itk_map = ItkMap(warp_path=itk_file)
seed_mask_definition = ImageFile(path=wm_mask_file)
stop_mask_definition = ImageFile(path=wm_mask_file)

# XXX Make ItkMap work at some point
# itk_map = ItkMap(warp_path=itk_file)

if tck_file is None:
tck_file = kwargs['import_tract']
kwargs.pop('import_tract', None)
if brain_mask_definition is None:
brain_mask_definition = kwargs['brain_mask_definition']
kwargs.pop('brain_mask_definition', None)

tracking_params = kwargs.pop('tracking_params', None)
if tracking_params is not None:
if tracking_params["seed_mask"] == "WM_prob":
tracking_params["seed_mask"] = seed_mask_definition
if tracking_params["stop_mask"] == "WM_prob":
tracking_params["stop_mask"] = stop_mask_definition

# if itk_map is None: # Use pyAFQ internal mapping
# itk_map = kwargs['mapping_definition']
# kwargs.pop('mapping_definition', None)
Expand All @@ -100,6 +114,7 @@ def _run_interface(self, runtime):
import_tract=tck_file,
brain_mask_definition=brain_mask_definition,
# mapping_definition=itk_map,
tracking_params=tracking_params,
**kwargs)

if "export" not in kwargs or kwargs["export"] == "all":
Expand Down
1 change: 1 addition & 0 deletions qsiprep/workflows/recon/pyafq.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def init_pyafq_wf(omp_nthreads, available_anatomical_data,
('bval_file', 'bval_file'),
('bvec_file', 'bvec_file'),
('dwi_mask', 'mask_file'),
('wm_mask', 'wm_mask_file'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattcieslak : what should we put here for wm_mask?

('t1_2_mni_reverse_transform', 'itk_file')]),
(run_afq, outputnode, [('afq_dir', 'afq_dir')])
])
Expand Down