-
Notifications
You must be signed in to change notification settings - Fork 34
Improvements on dependencies calculations #172
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
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8fc3759
refactor get_metadata
Remi-Gau c5655eb
reorganize dependencies
Remi-Gau ea8f072
adapted query for metadata
04c86e1
fix test and lint
Remi-Gau 97bb20d
remove dead code
Remi-Gau 91f5064
minor fixes on get_metadata
Remi-Gau 9d37614
rename functions to use snake_case
Remi-Gau ea6bb9b
refactor dependency indexing
Remi-Gau 2ca4496
get rid of parse_perf
Remi-Gau ffda8dc
remove commented out dead code
Remi-Gau db812da
add comments
Remi-Gau 53f6156
remove extra IF block
Remi-Gau d332496
ASL jpg file handled like other dependency files
Remi-Gau 6bfd46f
update ASL query tests to make sure context file dependency is indexed
Remi-Gau 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function res = ends_with(str, pattern) | ||
% | ||
% Checks id character array 'str' ends with 'pat' | ||
% | ||
% USAGE res = bids.internal.endsWith(str, pat) | ||
% | ||
% str - character array | ||
% pat - character array | ||
% | ||
% __________________________________________________________________________ | ||
% | ||
% Based on spm_file.m and spm_select.m from SPM12. | ||
% __________________________________________________________________________ | ||
|
||
% Copyright (C) 2011-2018 Guillaume Flandin, Wellcome Centre for Human Neuroimaging | ||
res = false; | ||
l_pat = length(pattern); | ||
if l_pat > length(str) | ||
return | ||
end | ||
res = strcmp(str(end - l_pat + 1:end), pattern); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
function metalist = get_meta_list(filename, pattern) | ||
% | ||
% Read a BIDS's file metadata according to the inheritance principle | ||
% | ||
% USAGE:: | ||
% | ||
% meta = bids.internal.get_metadata(filename, pattern = '^.*%s\\.json$') | ||
% | ||
% :param filename: fullpath name of file following BIDS standard | ||
% :type filename: string | ||
% :param pattern: Regular expression matching the metadata file (default is ``'^.*%s\\.json$'``) | ||
% If provided, it must at least be ``'%s'``. | ||
% :type pattern: string | ||
% | ||
% | ||
% metalist - list of paths to metafiles | ||
% __________________________________________________________________________ | ||
|
||
% Copyright (C) 2016-2018, Guillaume Flandin, Wellcome Centre for Human Neuroimaging | ||
% Copyright (C) 2018--, BIDS-MATLAB developers | ||
|
||
if nargin == 1 | ||
pattern = '^.*%s\\.json$'; | ||
end | ||
|
||
pth = fileparts(filename); | ||
p = bids.internal.parse_filename(filename); | ||
metalist = {}; | ||
|
||
N = 3; | ||
|
||
% -There is a session level in the hierarchy | ||
if isfield(p.entities, 'ses') && ~isempty(p.entities.ses) | ||
N = N + 1; | ||
end | ||
|
||
% -Loop from the directory where the file of interest is back to the | ||
% top level of the BIDS hierarchy | ||
for n = 1:N | ||
|
||
% -List the potential metadata files associated with this file suffix type | ||
% Default is to assume it is a JSON file | ||
metafile = bids.internal.file_utils('FPList', pth, sprintf(pattern, p.suffix)); | ||
|
||
if isempty(metafile) | ||
metafile = {}; | ||
else | ||
metafile = cellstr(metafile); | ||
end | ||
|
||
% -For all those files we find which one is potentially associated with | ||
% the file of interest | ||
for i = 1:numel(metafile) | ||
|
||
p2 = bids.internal.parse_filename(metafile{i}); | ||
entities = {}; | ||
if isfield(p2, 'entities') | ||
entities = fieldnames(p2.entities); | ||
end | ||
|
||
% -Check if this metadata file contains the same entity-label pairs as its | ||
% data file counterpart | ||
ismeta = true; | ||
for j = 1:numel(entities) | ||
if ~isfield(p.entities, entities{j}) || ... | ||
~strcmp(p.entities.(entities{j}), p2.entities.(entities{j})) | ||
ismeta = false; | ||
break | ||
end | ||
end | ||
|
||
% append path to list | ||
if ismeta | ||
metalist{end + 1, 1} = metafile{i}; %#ok<AGROW> | ||
end | ||
|
||
end | ||
|
||
% -Go up to the parent folder | ||
pth = fullfile(pth, '..'); | ||
end | ||
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,23 @@ | ||
function res = starts_with(str, pattern) | ||
% | ||
% Checks id character array 'str' starts with 'pat' | ||
% | ||
% USAGE res = bids.internal.startsWith(str, pat) | ||
% | ||
% str - character array | ||
% pat - character array | ||
% | ||
% __________________________________________________________________________ | ||
% | ||
% Based on spm_file.m and spm_select.m from SPM12. | ||
% __________________________________________________________________________ | ||
|
||
% Copyright (C) 2011-2018 Guillaume Flandin, Wellcome Centre for Human Neuroimaging | ||
res = false; | ||
l_pat = length(pattern); | ||
if l_pat > length(str) | ||
return | ||
end | ||
res = strcmp(str(1:l_pat), pattern); | ||
|
||
end |
Oops, something went wrong.
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.