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

[FIX] mat 7.3 support for SPM.mat files #3650

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

adamnarai
Copy link

@adamnarai adamnarai commented May 23, 2024

Summary

Fixes #2162
Fixes #3432

List of changes proposed in this PR (pull-request)

  • Replace sio.loadmat with a load function specific for SPM.mat files, so it also supports >2 GB mat 7.3 HDR files
  • Fix MATLAB's test_run_interface which I also encountered while running the tests

Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 6.97674% with 40 lines in your changes missing coverage. Please review.

Project coverage is 70.79%. Comparing base (e03ab6f) to head (b330385).

Files with missing lines Patch % Lines
nipype/utils/filemanip.py 5.12% 36 Missing and 1 partial ⚠️
nipype/interfaces/spm/model.py 33.33% 2 Missing ⚠️
nipype/interfaces/tests/test_matlab.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3650      +/-   ##
==========================================
- Coverage   70.83%   70.79%   -0.05%     
==========================================
  Files        1276     1276              
  Lines       59320    59357      +37     
  Branches     9826     9835       +9     
==========================================
+ Hits        42019    42021       +2     
- Misses      16125    16159      +34     
- Partials     1176     1177       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

outputs = self._outputs().get()
pth = os.path.dirname(self.inputs.spm_mat_file)
outtype = "nii" if "12" in self.version.split(".")[0] else "img"
spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False)
spm = load_spm_mat(self.inputs.spm_mat_file, struct_as_record=False)
Copy link
Member

Choose a reason for hiding this comment

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

It would be cleaner to break out the functionality you have into its own function and put the try/catch logic here.

Suggested change
spm = load_spm_mat(self.inputs.spm_mat_file, struct_as_record=False)
try:
spm = sio.loadmat(self.inputs.spm_mat_file, struct_as_record=False)
except NotImplementedError: # Matlab 7.3+
spm = load_spm_mat(self.inputs.spm_mat_file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MATLAB's test_run_interface FAILS HDF5 issue with matlab: Large .mat files need to be saved with -v 7.3
2 participants