-
Notifications
You must be signed in to change notification settings - Fork 80
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
Rezipping in fmri_data may be unnecessary #60
Comments
Note: the original approach was apparently to use the host system's
and there deletion of the original .gz would be the default (overridable by |
(oops, didn't mean to close this prematurely above... doh) The above PR is designed to address efficiency related to zip with a minimal change -- just avoid an expensive and unnecessary call to A separate issue that could be fixed by a deeper change is that
Though in a way conceptually simpler, this approach would affect |
Currently fmri_data will uncompress .nii.gz inputs automatically using gunzip_image_names_if_gz:
[image_names, was_gzipped] = gunzip_image_names_if_gz(image_names);
This allows it to read .nii files. Depending on MATLAB
gunzip
and whether it deletes the original, this would result in either two files (.nii and .nii.gz) or just the .nii version. As housekeeping,fmri_data
apparently assumes the latter as the worst case and rezips:where
re_zip_images
is a subfunction offmri_data
that calls MATLAB'sgzip
. Thisgzip
call overwrites a .nii.gz if it exists, andre_zip_images
then removes the .nii:This approach is unfortunately extremely costly, as
gzip
may take around 10x as much time asgunzip
, and would seem to be totally unnecessary if the .nii.gz was in fact not deleted bygunzip
. Also, it would seem that a replacement of .nii.gz files may invalidate cryptographic hashes calculated on the original.So, one simple improvement would be to make the "housekeeping" step conditional, and if a .nii.gz exists remove the .nii instead.
In fact, the documentation for MATLAB's
gzip
(R2024a) saysand this seems to be true as well for past versions, so while OK to have that conditional "just in case" it seems rezip should be 100% avoidable here?
The text was updated successfully, but these errors were encountered: