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

Update fmri_data.m to avoid rezip #61

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions CanlabCore/@fmri_data/fmri_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -680,18 +680,30 @@
for i = 1:size(image_names, 1)

if was_gzipped(i)

% modification 9/24 by jcf2:
% We expect to have both original .nii.gz and a .nii created by unzip at
% this point (note that MATLAB unzip does not delete original .gz), so
% we expect *not* to have to rezip the .nii, as was the case when using
% a 'system('unzip ...')' call. Leaving that rezip option in case of a future
% switch, but note 'system('unzip --keep' ...') could also be used to avoid.

% Use system to remove unzipped version after zipping.
% Will wait for input, and not overwrite, if images exist
% [status, result] = system(['gzip ' image_names(i, :)]);
if exist([deblank(image_names_out{i}) '.gz'], 'file')

try
gzip(deblank(image_names(i, :)));
% keep original .nii.gz, delete created .nii
delete(deblank(image_names(i, :)))
image_names_out{i} = [deblank(image_names_out{i}) '.gz'];

catch
warning('Error writing .gz images. Check permissions (or maybe using Git Annex?');
image_names_out{i} = [deblank(image_names_out{i}) '.gz'];

else

% can't find .nii.gz (?!) so need to recreate; still need to delete .nii
try
gzip(deblank(image_names(i, :)));
delete(deblank(image_names(i, :)))
image_names_out{i} = [deblank(image_names_out{i}) '.gz'];
catch
warning('Error writing .gz images. Check permissions (or maybe using Git Annex?');
end

end
end
Expand Down