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

[ENH] add basic filename, path and derivatives JSON creation #203

Merged
merged 17 commits into from
May 24, 2021

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Apr 17, 2021

Starts addressing #47 and #79

Nothing crazy.

Reuses the output structure of parse_filename as inputs to make it easier to pass it around.

    %% Create filename
    p.suffix = 'bold';
    p.ext = '.nii';
    p.entities = struct(...
                        'sub', '01', ...
                        'ses', 'test', ...
                        'task', 'face recognition', ...
                        'run', '02');
    
    filename = bids.util.create_filename(p);
    
    assertEqual(filename, 'sub-01_ses-test_task-faceRecognition_run-02_bold.nii');
    
    %% Modify existing filename
    p.entities = struct(...
        'sub', '02', ...
        'task', 'new task');
    
    filename = bids.util.create_filename(p, fullfile(pwd,filename));
    
    assertEqual(filename, 'sub-02_ses-test_task-newTask_run-02_bold.nii');    

    %% Remove entity from filename
    p.entities = struct('ses', '');

    filename = bids.util.create_filename(p, filename);
    
    assertEqual(filename, 'sub-02_task-newTask_run-02_bold.nii');

Could be added:

  • a way to "sort" the entities to create the filename. When none is provided, it would rely on the BIDS schema for valid suffix + entities. When we are dealing with non bids valid suffixes, thenwe default to the way they are entered in the structure.
  • a way to make camel case optional
  • a way to help with path construction for a given file
  • add an option to make sure the file follows the bids schema
  • for derivatives (with desc entity), return the name and dummy content of associated json fille

@codecov
Copy link

codecov bot commented Apr 17, 2021

Codecov Report

Merging #203 (1435c73) into dev (f7ea16c) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev    #203    +/-   ##
======================================
  Coverage   0.00%   0.00%            
======================================
  Files         29      37     +8     
  Lines       1060    1221   +161     
======================================
- Misses      1060    1221   +161     
Flag Coverage Δ
unittests 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
+bids/+internal/append_to_layout.m 0.00% <0.00%> (ø)
+bids/+internal/camel_case.m 0.00% <0.00%> (ø)
+bids/+internal/parse_filename.m 0.00% <0.00%> (ø)
+bids/+schema/find_suffix_datatypes.m 0.00% <0.00%> (ø)
+bids/+schema/find_suffix_group.m 0.00% <0.00%> (ø)
+bids/+schema/return_entities_for_suffix.m 0.00% <0.00%> (ø)
+bids/create_filename.m 0.00% <0.00%> (ø)
+bids/create_path.m 0.00% <0.00%> (ø)
+bids/derivatives_json.m 0.00% <0.00%> (ø)
+bids/copy_to_derivative.m 0.00% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7ea16c...1435c73. Read the comment docs.

@Remi-Gau Remi-Gau changed the title [ENH] add basic filename creation [ENH] add basic filename, path and derivatives JSON creation May 24, 2021
@Remi-Gau Remi-Gau merged commit 4ecf807 into bids-standard:dev May 24, 2021
@Remi-Gau Remi-Gau deleted the remi-filename branch May 24, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant