Skip to content

Commit 4581e4c

Browse files
committed
Merge pull request #333 from chrisfilo/fix/csv
Fix/csv
2 parents 711c564 + a235ec8 commit 4581e4c

File tree

7 files changed

+28
-11
lines changed

7 files changed

+28
-11
lines changed

examples/dmri_connectivity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def select_aparc_annot(list_of_files):
551551
mapping.connect([(gpickledNetworks, CFFConverter,[("out","gpickled_networks")])])
552552
mapping.connect([(niftiVolumes, CFFConverter,[("out","nifti_volumes")])])
553553
mapping.connect([(fiberDataArrays, CFFConverter,[("out","data_files")])])
554-
mapping.connect([(camino2trackvis, CFFConverter,[("trackvis","tract_files")])])
554+
mapping.connect([(creatematrix, CFFConverter,[("filtered_tractographies","tract_files")])])
555555
mapping.connect([(inputnode, CFFConverter,[("subject_id","title")])])
556556

557557
"""

examples/dmri_connectivity_advanced.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268

269269
probCSDstreamtrack = pe.Node(interface=mrtrix.ProbabilisticSphericallyDeconvolutedStreamlineTrack(),name='probCSDstreamtrack')
270270
probCSDstreamtrack.inputs.inputmodel = 'SD_PROB'
271-
probCSDstreamtrack.inputs.maximum_number_of_tracks = 150000
271+
probCSDstreamtrack.inputs.desired_number_of_tracks = 150000
272272
tracks2prob = pe.Node(interface=mrtrix.Tracks2Prob(),name='tracks2prob')
273273
tracks2prob.inputs.colour = True
274274
MRconvert_tracks2prob = MRconvert_fa.clone(name='MRconvert_tracks2prob')
@@ -542,7 +542,7 @@
542542
mapping.connect([(creatematrix, CFFConverter,[("matrix_files","gpickled_networks")])])
543543
mapping.connect([(niftiVolumes, CFFConverter,[("out","nifti_volumes")])])
544544
mapping.connect([(fiberDataArrays, CFFConverter,[("out","data_files")])])
545-
mapping.connect([(creatematrix, CFFConverter,[("filtered_tractography","tract_files")])])
545+
mapping.connect([(creatematrix, CFFConverter,[("filtered_tractographies","tract_files")])])
546546
mapping.connect([(inputnode, CFFConverter,[("subject_id","title")])])
547547

548548
"""

nipype/interfaces/cmtk/cmtk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class CreateMatrixOutputSpec(TraitedSpec):
415415
fiber_labels_noorphans = File(desc='Saved Numpy array with the labels for each non-orphan fiber', exists=True)
416416
filtered_tractography = File(desc='TrackVis file containing only those fibers originate in one and terminate in another region', exists=True)
417417
filtered_tractography_by_intersections = File(desc='TrackVis file containing all fibers which connect two regions', exists=True)
418+
filtered_tractographies = OutputMultiPath(File(desc='TrackVis file containing only those fibers originate in one and terminate in another region', exists=True))
418419

419420
class CreateMatrix(BaseInterface):
420421
"""
@@ -535,6 +536,7 @@ def _list_outputs(self):
535536

536537
_, name , _ = split_filename(self.inputs.tract_file)
537538
outputs['filtered_tractography'] = op.abspath(name + '_streamline_final.trk')
539+
outputs['filtered_tractographies'] = [outputs['filtered_tractography'], outputs['filtered_tractography_by_intersections']]
538540
return outputs
539541

540542
def _gen_outfilename(self, ext):

nipype/interfaces/cmtk/convert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _run_interface(self, runtime):
138138
count = 0
139139
if isdefined(self.inputs.tract_files):
140140
for trk in self.inputs.tract_files:
141-
trk_name = 'Tract file {cnt}'.format(cnt=count)
141+
_, trk_name, _ = split_filename(trk)
142142
ctrack = cf.CTrack(trk_name, trk)
143143
a.add_connectome_track(ctrack)
144144
count += 1

nipype/interfaces/cmtk/parcellation.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,28 @@ def crop_and_move_datasets(subject_id, subjects_dir, fs_dir, parcellation_name,
350350
mri_cmd = 'mri_convert -rl "%s" -rt nearest "%s" -nc "%s"' % (orig, d[0], d[1])
351351
runCmd( mri_cmd,log )
352352

353+
353354
class ParcellateInputSpec(BaseInterfaceInputSpec):
354355
subject_id = traits.String(mandatory=True, desc='Subject ID')
355-
parcellation_name = traits.Enum('scale500', ['scale33', 'scale60', 'scale125', 'scale250','scale500'], usedefault=True)
356+
parcellation_name = traits.Enum('scale500', ['scale33', 'scale60', 'scale125', 'scale250', 'scale500'], usedefault=True)
356357
freesurfer_dir = Directory(desc='Freesurfer main directory')
357358
subjects_dir = Directory(desc='Freesurfer main directory')
358-
out_roi_file = File(genfile = True, desc='Region of Interest file for connectivity mapping')
359+
out_roi_file = File(genfile=True, desc='Region of Interest file for connectivity mapping')
360+
359361

360362
class ParcellateOutputSpec(TraitedSpec):
361-
roi_file = File(desc='Region of Interest file for connectivity mapping')
363+
roi_file = File(desc='Region of Interest file for connectivity mapping',
364+
exists=True)
365+
white_matter_mask_file = File(desc='White matter mask file')
366+
cc_unknown_file = File(desc='Image file with regions labelled as unknown cortical structures',
367+
exists=True)
368+
ribbon_file = File(desc='Image file detailing the cortical ribbon',
369+
exists=True)
370+
aseg_file = File(desc='Automated segmentation file converted from Freesurfer "subjects" directory',
371+
exists=True)
372+
roi_file_in_structural_space = File(desc='ROI image resliced to the dimensions of the original structural image',
373+
exists=True)
374+
362375

363376
class Parcellate(BaseInterface):
364377
"""Subdivides segmented ROI file into smaller subregions
@@ -403,7 +416,7 @@ def _list_outputs(self):
403416
outputs['cc_unknown_file'] = op.abspath('cc_unknown.nii.gz')
404417
outputs['ribbon_file'] = op.abspath('ribbon.nii.gz')
405418
outputs['aseg_file'] = op.abspath('aseg.nii.gz')
406-
outputs['ROI_HR_th_file'] = op.abspath('ROI_HR_th.nii.gz')
419+
outputs['roi_file_in_structural_space'] = op.abspath('ROI_HR_th.nii.gz')
407420
return outputs
408421

409422
def _gen_outfilename(self, ext, prefix='ROI'):

nipype/workflows/dmri/connectivity/nx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import nipype.interfaces.utility as util
33
import nipype.interfaces.cmtk as cmtk
44
import nipype.algorithms.misc as misc
5+
from .group_connectivity import pullnodeIDs
56

67
def create_networkx_pipeline(name="networkx", extra_column_heading="subject"):
78
"""Creates a workflow to calculate various graph measures (via NetworkX) on
@@ -52,6 +53,7 @@ def create_networkx_pipeline(name="networkx", extra_column_heading="subject"):
5253
pipeline.connect([(Matlab2CSV_node, MergeCSVFiles_node,[("csv_files","in_files")])])
5354
pipeline.connect([(inputnode, MergeCSVFiles_node,[("extra_field","out_file")])])
5455
pipeline.connect([(inputnode, MergeCSVFiles_node,[("extra_field","extra_field")])])
56+
pipeline.connect([(inputnode, MergeCSVFiles_node, [(("network_file", pullnodeIDs), "row_headings")])])
5557

5658
pipeline.connect([(inputnode, mergeNetworks,[("network_file","in1")])])
5759
pipeline.connect([(ntwkMetrics, mergeNetworks,[("gpickled_network_files","in2")])])
@@ -67,7 +69,7 @@ def create_networkx_pipeline(name="networkx", extra_column_heading="subject"):
6769
pipeline.connect([(Matlab2CSV_global, mergeCSVs, [("csv_files", "in2")])])
6870
pipeline.connect([(mergeNetworks, outputnode, [("out", "network_files")])])
6971
pipeline.connect([(mergeCSVs, outputnode, [("out", "csv_files")])])
70-
pipeline.connect([(ntwkMetrics, outputnode,[("matlab_matrix_files","matlab_files")])])
72+
pipeline.connect([(ntwkMetrics, outputnode,[("matlab_matrix_files", "matlab_files")])])
7173
return pipeline
7274

7375
def create_cmats_to_csv_pipeline(name="cmats_to_csv", extra_column_heading="subject"):

nipype/workflows/dmri/mrtrix/connectivity_mapping.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def create_connectivity_pipeline(name="connectivity", parcellation_name='scale50
213213

214214
probCSDstreamtrack = pe.Node(interface=mrtrix.ProbabilisticSphericallyDeconvolutedStreamlineTrack(),name='probCSDstreamtrack')
215215
probCSDstreamtrack.inputs.inputmodel = 'SD_PROB'
216-
probCSDstreamtrack.inputs.maximum_number_of_tracks = 150000
216+
probCSDstreamtrack.inputs.desired_number_of_tracks = 150000
217217
tracks2prob = pe.Node(interface=mrtrix.Tracks2Prob(),name='tracks2prob')
218218
tracks2prob.inputs.colour = True
219219
MRconvert_tracks2prob = MRconvert_fa.clone(name='MRconvert_tracks2prob')
@@ -479,7 +479,7 @@ def create_connectivity_pipeline(name="connectivity", parcellation_name='scale50
479479
mapping.connect([(creatematrix, CFFConverter,[("matrix_files","gpickled_networks")])])
480480
mapping.connect([(niftiVolumes, CFFConverter,[("out","nifti_volumes")])])
481481
mapping.connect([(fiberDataArrays, CFFConverter,[("out","data_files")])])
482-
mapping.connect([(creatematrix, CFFConverter,[("filtered_tractography","tract_files")])])
482+
mapping.connect([(creatematrix, CFFConverter,[("filtered_tractographies","tract_files")])])
483483
mapping.connect([(inputnode_within, CFFConverter,[("subject_id","title")])])
484484

485485
"""

0 commit comments

Comments
 (0)