-
Notifications
You must be signed in to change notification settings - Fork 15
[ENH] add gzip scripts for raw folder #179
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
Merged
marcobarilari
merged 14 commits into
cpp-lln-lab:dev
from
marcobarilari:marco_zip-raw-folder
Nov 13, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bf85945
add main script for gzipping raw folder
marcobarilari ac887bd
update workflow script to gzip
marcobarilari 66b32b2
add spm batch for gzipping
marcobarilari b1c430d
update the example workflow
marcobarilari 04c95ac
fix doc error in setBatch3Dto4D
marcobarilari 19fa2d7
change errors to warnings
marcobarilari 1036a48
Update src/workflows/bidsGZipRawFolder.m
marcobarilari 225e14b
Update src/batches/setBatchGZip.m
marcobarilari d180fac
Update src/batches/setBatchGZip.m
marcobarilari 5d31a74
Update src/workflows/bidsGZipRawFolder.m
marcobarilari e3f7661
Update src/workflows/bidsGZipRawFolder.m
marcobarilari a80bd6b
update documentation
marcobarilari a8ae513
add test for checkOptionsSource
marcobarilari eefa8ae
add code to test fun checkOptionsSource
marcobarilari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| % (C) Copyright 2020 CPP BIDS SPM-pipeline developers | ||
|
|
||
| function matlabbatch = setBatchGZip(unzippedNiifiles, keepUnzippedNii) | ||
| % | ||
| % Set the batch for GZip the 4D volumes | ||
| % | ||
| % USAGE:: | ||
| % | ||
| % matlabbatch = setBatchGZip(unzippedNiifiles, keepUnzippedNii) | ||
| % | ||
| % :param unzippedNiifiles: List of volumes to be gzipped | ||
| % :type unzippedNiifiles: array | ||
| % :param keepUnzippedNii: Boolean to decide to delete the unzipped files | ||
| % :type keepUnzippedNii: boolean | ||
| % | ||
| % :returns: - :matlabbatch: (struct) The matlabbath ready to run the spm job | ||
|
|
||
| matlabbatch{1}.cfg_basicio.file_dir.file_ops.cfg_gzip_files.files = unzippedNiifiles; | ||
| matlabbatch{1}.cfg_basicio.file_dir.file_ops.cfg_gzip_files.outdir = {''}; | ||
| matlabbatch{1}.cfg_basicio.file_dir.file_ops.cfg_gzip_files.keep = keepUnzippedNii; | ||
|
|
||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| % (C) Copyright 2020 CPP BIDS SPM-pipeline developers | ||
|
|
||
| function bidsGZipRawFolder(optSource, keepUnzippedNii) | ||
|
|
||
| % | ||
| % GZip the nii files in a ``raw`` bids folders from the. It will do it independently of the task. | ||
| % | ||
| % USAGE:: | ||
| % | ||
| % bidsGZipRawFolder(optSource ... | ||
| % [, keepUnzippedNii = false]) | ||
| % | ||
| % :param optSource: The structure that contains the options set by the user to run the batch | ||
| % workflow for source processing | ||
| % :type opt: structure | ||
| % :param keepUnzippedNii: will keep the original ``.nii`` if set to ``true``. Default is false | ||
| % :type keepUnzippedNii: boolean | ||
|
|
||
| %% input variables default values | ||
|
|
||
|
|
||
| if nargin < 2 || isempty(keepUnzippedNii) | ||
| % delete the original unzipped .nii | ||
| keepUnzippedNii = false; | ||
| end | ||
|
|
||
| tic; | ||
|
|
||
| printWorklowName('GZip data'); | ||
|
|
||
| rawDir = optSource.dataDir; | ||
|
|
||
| unzippedNiifiles = cellstr(spm_select('FPListRec', rawDir, '^.*.nii$')); | ||
|
|
||
| matlabbatch = setBatchGZip(unzippedNiifiles, keepUnzippedNii); | ||
|
|
||
| spm_jobman('run', matlabbatch); | ||
|
|
||
| toc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| function test_suite = test_checkOptionsSource %#ok<*STOUT> | ||
| try % assignment of 'localfunctions' is necessary in Matlab >= 2016 | ||
| test_functions = localfunctions(); %#ok<*NASGU> | ||
| catch % no problem; early Matlab versions can use initTestSuite fine | ||
| end | ||
| initTestSuite; | ||
| end | ||
|
|
||
| function test_checkOptionsSourceBasic() | ||
|
|
||
| optSource.nbDummies = 0; | ||
| optSource = checkOptionsSource(optSource); | ||
|
|
||
| expectedOptionsSource = defaultOptionsSource(); | ||
| expectedOptionsSource.nbDummies = 0; | ||
|
|
||
| assertEqual(optSource, expectedOptionsSource); | ||
|
|
||
| end | ||
|
|
||
| function test_checkOptionsSourceDoNotOverwrite() | ||
|
|
||
| optSource.dataType = 666; | ||
| optSource.someExtraField = 'test'; | ||
| optSource.nbDummies = 42; | ||
|
|
||
| optSource = checkOptionsSource(optSource); | ||
|
|
||
| assertEqual(optSource.dataType, 666); | ||
| assertEqual(optSource.someExtraField, 'test'); | ||
| assertEqual(optSource.nbDummies, 42); | ||
|
|
||
| end | ||
|
|
||
| function expectedOptionsSource = defaultOptionsSource() | ||
|
|
||
| expectedOptionsSource.sourceDir = ''; | ||
|
|
||
| expectedOptionsSource.dataDir = ''; | ||
|
|
||
| expectedOptionsSource.sequenceToIgnore = {}; | ||
|
|
||
| expectedOptionsSource.dataType = 0; | ||
|
|
||
| expectedOptionsSource.zip = 0; | ||
|
|
||
| expectedOptionsSource.nbDummies = 0; | ||
|
|
||
| expectedOptionsSource.sequenceRmDummies = {}; | ||
|
|
||
| end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.