-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from Remi-Gau/rm_data
[ENH] refactor removing date entity and allow to use bids fitler to only convert certain files from source to raw
- Loading branch information
Showing
4 changed files
with
245 additions
and
146 deletions.
There are no files selected for viewing
This file contains 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 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 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,41 @@ | ||
function removeDateEntity(varargin) | ||
% | ||
% Removes the date entity from all the files in a BIDS data set | ||
% | ||
% | ||
% USAGE:: | ||
% | ||
% removeDateEntity(pathToDataSet, 'filter', filter) | ||
% | ||
% | ||
% (C) Copyright 2022 CPP_BIDS developers | ||
|
||
args = inputParser; | ||
|
||
default_filter = struct([]); | ||
|
||
args.addRequired('pathToDataSet', @isdir); | ||
args.addParameter('filter', default_filter, @isstruct); | ||
|
||
args.parse(varargin{:}); | ||
|
||
pathToDataSet = args.Results.pathToDataSet; | ||
filter = args.Results.filter; | ||
|
||
BIDS = bids.layout(pathToDataSet, 'use_schema', false); | ||
|
||
filter.date = '[0-9]+'; | ||
data = bids.query(BIDS, 'data', filter); | ||
metadata = bids.query(BIDS, 'metadata', filter); | ||
|
||
for i = 1:size(data, 1) | ||
bf = bids.File(data{i}); | ||
% TODO probably JSON renaming should be passed to bids-matlab | ||
sourceJson = fullfile(fileparts(bf.path), bf.json_filename); | ||
bf.entities.date = ''; | ||
bf.rename('dry_run', false, 'force', true); | ||
bids.util.jsonencode(fullfile(fileparts(bf.path), bf.json_filename), metadata{i}); | ||
delete(sourceJson); | ||
end | ||
|
||
end |
Oops, something went wrong.