Skip to content

Commit

Permalink
new version with truncation happening in copy_inputs method
Browse files Browse the repository at this point in the history
  • Loading branch information
danielasay committed Jun 26, 2024
1 parent d97aeab commit 7379076
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dwiqc/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'dwiqc'
__description__ = 'Quality Assurance Pipeline for Diffusion MR Data'
__url__ = 'https://github.com/harvard-nrg/dwiqc'
__version__ = '1.6.3'
__version__ = '1.6.4'
__author__ = 'Neuroinformatics Research Group'
__author_email__ = 'info@neuroinfo.org'
28 changes: 15 additions & 13 deletions dwiqc/tasks/prequal.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,30 @@ def copy_inputs(self, inputs_dir):

all_files = self._layout.get(subject=self._sub, session=self._ses, return_type='filename') # get a list of all of the subject's files

# remove all non b0volumes from the fieldmaps. return a list of paths to newly truncated files

fmap_files = self._layout.get(subject=self._sub, session=self._ses, suffix='epi', extension='.nii.gz', return_type='filename')

if not fmap_files:
self._layout.get(subject=self._sub, session=self._ses, suffix='epi', extension='.nii', return_type='filename')

# truncate down the fmap files to include just b0 volumes

truncated_fmaps = self.truncate_fmaps(fmap_files, inputs_dir)

# copy the all the subject's files into the INPUTS directory
for file in all_files:
basename = os.path.basename(file)
dest = os.path.join(inputs_dir, basename)
shutil.copy(file, dest)

self.create_bfiles(inputs_dir)
self.create_bfiles(inputs_dir, truncated_fmaps)


# the fieldmap data needs accompanying 'dummy' bval and bvec files that consist of 0's
def create_bfiles(self, inputs_dir):
def create_bfiles(self, inputs_dir, truncated_fmaps):
# get a list of all the fmap files that end with .json (this it's helpful to have a file with just one extension)

fmap_files = self._layout.get(subject=self._sub, session=self._ses, suffix='epi', extension='.nii.gz', return_type='filename')

if not fmap_files:
self._layout.get(subject=self._sub, session=self._ses, suffix='epi', extension='.nii', return_type='filename')

# truncate down the fmap files to include just b0 volumes

truncated_fmaps = self.truncate_fmaps(fmap_files, inputs_dir)

# get the basename of the file and then remove the extension
for fmap in truncated_fmaps:

Expand Down Expand Up @@ -134,11 +136,11 @@ def truncate_fmaps(self, fmap_files, inputs_dir):
cmd = [
'singularity',
'exec',
'--pwd', inputs_dir,
'--pwd', fmap_dir,
self._fsl_sif,
'/APPS/fsl/bin/fslselectvols',
'-i', fmap_basename,
'-o', f'{inputs_dir}/{fmap_basename}',
'-o', fmap_basename,
'--vols=0'
]
#logger.info(f'running {json.dumps(cmd, indent=2)} on {fmap}')
Expand Down

0 comments on commit 7379076

Please sign in to comment.