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

Merged
merged 3 commits into from
Oct 31, 2024
Merged

Conversation

adamnarai
Copy link
Contributor

@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 5.00000% with 38 lines in your changes missing coverage. Please review.

Project coverage is 70.46%. Comparing base (e03ab6f) to head (bd0d585).
Report is 102 commits behind head on master.

Files with missing lines Patch % Lines
nipype/utils/filemanip.py 2.77% 35 Missing ⚠️
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.46%   -0.37%     
==========================================
  Files        1276     1277       +1     
  Lines       59320    59153     -167     
  Branches     9826     8590    -1236     
==========================================
- Hits        42019    41685     -334     
- Misses      16125    16340     +215     
+ Partials     1176     1128      -48     

☔ 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)

@effigies effigies merged commit 00c490c into nipy:master Oct 31, 2024
12 of 13 checks passed
@effigies effigies mentioned this pull request Oct 31, 2024
6 tasks
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