Skip to content

Commit fbd9b3c

Browse files
committed
fix the truncation so that all fmap files get truncated
1 parent dab826d commit fbd9b3c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

dwiqc/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = 'dwiqc'
22
__description__ = 'Quality Assurance Pipeline for Diffusion MR Data'
33
__url__ = 'https://github.com/harvard-nrg/dwiqc'
4-
__version__ = '1.6.6'
4+
__version__ = '1.6.7'
55
__author__ = 'Neuroinformatics Research Group'
66
__author_email__ = 'info@neuroinfo.org'

dwiqc/tasks/qsiprep.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,23 @@ def extract_vols(self, dwi_full_path, dwi_basename):
353353

354354
self.insert_json_value('IntendedFor', f'ses-{self._ses}/dwi/{dwi_basename}', fmap_json_file_path)
355355

356-
if self._truncate_fmap:
357-
shape = nib.load(fmap_path).get_fdata().shape
356+
357+
def execute_fmap_truncation(self)
358+
"""
359+
If truncate fmaps is true, this method will go through all of the fmaps in the fmap BIDS dir and make sure they are only one volume in length
360+
"""
361+
if self._truncate_fmap:
362+
fmap_files = self._layout.get(subject=self._sub, session=self._ses, suffix='epi', extension='.nii.gz', return_type='filename')
363+
364+
for fmap in fmap_files:
365+
shape = nib.load(fmap).get_fdata().shape
358366
if len(shape) == 4:
359367
num_vols = shape[3]
368+
if num_vols == 1:
369+
continue
360370
middle_vol = num_vols // 2
361371

362-
self.run_fslroi(fmap_path, middle_vol)
372+
self.run_fslroi(fmap, middle_vol)
363373

364374
def run_fslroi(self, fmap, volume):
365375
vol_index = int(volume) - 1
@@ -529,6 +539,7 @@ def build(self):
529539
self.check_output_resolution()
530540
self.check_fieldmaps()
531541
self.delete_bval_bvec()
542+
self.execute_fmap_truncation()
532543
try:
533544
qsiprep_command = yaml.safe_load(open(self._qsiprep_config))
534545
except yaml.parser.ParserError:

0 commit comments

Comments
 (0)