PennLINC / aslprep

Preprocessing of arterial spin labeling (ASL) data
https://aslprep.readthedocs.io
Other
41 stars 15 forks source link

Fix nibabel import #301

Closed tsalo closed 1 year ago

tsalo commented 1 year ago

Closes #300.

Changes proposed in this pull request

Luoyu-Wang commented 1 year ago

Thank you for your patience, and I would like to ask you another question. Whenever I use ASLprep, I find myself having to download the tpl-MNI152NLin2009cAsym_from-MNI152NLin6Asym_mode-image_xfm.h5 file every time I run the process. Is there a way to avoid repeated downloads?

Additionally, I wanted to mention that tomorrow we will be installing ASL sequences based on multi-PLD on our lab GE machine. I was wondering if ASLprep could handle this type of data. I'm looking forward to your response.

tsalo commented 1 year ago

Thank you for your patience, and I would like to ask you another question. Whenever I use ASLprep, I find myself having to download the tpl-MNI152NLin2009cAsym_from-MNI152NLin6Asym_mode-image_xfm.h5 file every time I run the process. Is there a way to avoid repeated downloads?

You can pre-cache templates on your machine and then mount the templateflow folder to your container. Since ASLPrep is built off of fMRIPrep, the instructions on this page should work.

Additionally, I wanted to mention that tomorrow we will be installing ASL sequences based on multi-PLD on our lab GE machine. I was wondering if ASLprep could handle this type of data.

I haven't tried out ASLPrep on multi-PLD data from a GE scanner, but I believe it should be fine as long as the sequence is PCASL. We don't have multi-delay PASL supported at the moment (see #272).

Luoyu-Wang commented 1 year ago

Thanks for your reply and I will try it out.

Luoyu-Wang commented 1 year ago

We pulled the latest docker version(0.4.0) and replaced the ge.py file, but there were 3 errors reported, what is the reason for this?

error1: Node: aslprep_wf.single_subject_101_wf.anat_preproc_wf.anat_derivatives_wf.gen_ref Working directory: /work/aslprep_wf/single_subject_101_wf/anat_preproc_wf/anat_derivatives_wf/_in_tuple_MNI152NLin2009cAsym.resnative/gen_ref

Node inputs:

fixed_image = fov_mask = None keep_native = True moving_image = xform_code = None

Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node result["result"] = node.run(updatehash=updatehash) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run result = self._run_interface(execute=True) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface return self._run_command(execute) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command raise NodeExecutionError(msg) nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node gen_ref.

Traceback: Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run runtime = self._run_interface(runtime) File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/nibabel.py", line 430, in _run_interface self._results["out_file"] = _gen_reference( File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/nibabel.py", line 609, in _gen_reference resampled = nli.resample_img( File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/image/resampling.py", line 445, in resample_img img = _utils.check_niimg(img) File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg_conversions.py", line 286, in check_niimg niimg = load_niimg(niimg, dtype=dtype) File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg.py", line 137, in load_niimg dtype = _get_target_dtype(_get_data(niimg).dtype, dtype) File "/usr/local/miniconda/lib/python3.8/site-packages/nilearn/_utils/niimg.py", line 26, in _get_data data = np.asanyarray(img._dataobj) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 426, in array arr = self._get_scaled(dtype=dtype, slicer=()) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 393, in _get_scaled scaled = apply_read_scaling(self._get_unscaled(slicer=slicer), scl_slope, scl_inter) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 363, in _get_unscaled return array_from_file( File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/volumeutils.py", line 461, in array_from_file raise OSError( OSError: Expected 17060042 bytes, got 17053871 bytes from object

error2: Node: aslprep_wf.single_subject_101_wf.anat_preproc_wf.anat_norm_wf.registration Working directory: /work/aslprep_wf/single_subject_101_wf/anat_preproc_wf/anat_norm_wf/_template_MNI152NLin2009cAsym/registration

Node inputs:

explicit_masking = True flavor = precise float = True initial_moving_transform = lesion_mask = moving = T1w moving_image = moving_mask = num_threads = 5 orientation = RAS reference = T1w reference_image = reference_mask = settings = template = MNI152NLin2009cAsym template_resolution = template_spec =

Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node result["result"] = node.run(updatehash=updatehash) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run result = self._run_interface(execute=True) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface return self._run_command(execute) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command raise NodeExecutionError(msg) nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node registration.

Traceback: Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run runtime = self._run_interface(runtime) File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/norm.py", line 183, in _run_interface ants_args = self._get_ants_args() File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/norm.py", line 457, in _get_ants_args args["fixed_image"] = mask( File "/usr/local/miniconda/lib/python3.8/site-packages/niworkflows/interfaces/norm.py", line 506, in mask data = in_nii.get_fdata() File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/dataobj_images.py", line 368, in get_fdata data = np.asanyarray(self._dataobj, dtype=dtype) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 426, in array arr = self._get_scaled(dtype=dtype, slicer=()) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 393, in _get_scaled scaled = apply_read_scaling(self._get_unscaled(slicer=slicer), scl_slope, scl_inter) File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/arrayproxy.py", line 363, in _get_unscaled return array_from_file( File "/usr/local/miniconda/lib/python3.8/site-packages/nibabel/volumeutils.py", line 461, in array_from_file raise OSError( OSError: Expected 17060042 bytes, got 17053871 bytes from object

error3: Node: aslprep_wf.single_subject_101_wf.asl_preproc_asl.asl_t1_trans_wf.asl_to_t1w_transform Working directory: /work/aslprep_wf/single_subject_101_wf/asl_preproc_asl/asl_t1_trans_wf/asl_to_t1w_transform

Node inputs:

args = copy_dtype = True default_value = 0.0 dimension = environ = {} float = True input_image = input_image_type = interpolation = LanczosWindowedSinc interpolation_parameters = invert_transform_flags = num_threads = 5 out_postfix = _trans output_image = print_out_composite_warp_file = reference_image = save_cmd = True transforms =

Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/plugins/multiproc.py", line 67, in run_node result["result"] = node.run(updatehash=updatehash) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 527, in run result = self._run_interface(execute=True) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 645, in _run_interface return self._run_command(execute) File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/pipeline/engine/nodes.py", line 771, in _run_command raise NodeExecutionError(msg) nipype.pipeline.engine.nodes.NodeExecutionError: Exception raised while executing Node asl_to_t1w_transform.

Traceback: Traceback (most recent call last): File "/usr/local/miniconda/lib/python3.8/site-packages/nipype/interfaces/base/core.py", line 397, in run runtime = self._run_interface(runtime) File "/usr/local/miniconda/lib/python3.8/site-packages/aslprep/niworkflows/interfaces/itk.py", line 177, in _run_interface tmp_folder.cleanup() File "/usr/local/miniconda/lib/python3.8/tempfile.py", line 832, in cleanup self._rmtree(self.name) File "/usr/local/miniconda/lib/python3.8/tempfile.py", line 814, in _rmtree _shutil.rmtree(name, onerror=onerror) File "/usr/local/miniconda/lib/python3.8/shutil.py", line 719, in rmtree onerror(os.rmdir, path, sys.exc_info()) File "/usr/local/miniconda/lib/python3.8/shutil.py", line 717, in rmtree os.rmdir(path) OSError: [Errno 26] Text file busy: '/work/aslprep_wf/single_subject_101_wf/asl_preproc_asl/asl_t1_trans_wf/asl_to_t1w_transform/tmp-qtx8k5tj'

tsalo commented 1 year ago

@Luoyu-Wang thank you for following up. I have opened a new issue with your traceback and I'll follow up there.