I wonder if it’s possible to ‘swap’ the folder hierarchy that DataSink creates? I would like to come from this folder hierarchy
output/derivatives/subjects/
└── 100610
└── gambling
└── first_level_design_spm_mat_file
└── _subject_id_100610
├── _design_type_block
│ └── SPM.mat
└── _design_type_event
└── SPM.mat
…to this one (I ran both a block and event-designed first-level analysis and it would make more sense if all files would be nested within those two variants of my analysis):
output/derivatives/subjects/
└── 100610
└── gambling
├── block
│ └── first_level_design_spm_mat_file
│ └── SPM.mat
└── event
└── first_level_design_spm_mat_file
└── SPM.mat
I know that I can replace _design_type_block with block and_design_type_event with event using the substitutions argument. I also know that I could delete _subject_id_100610 by using regexp_substitutions.. But this would only lead me to:
output/derivatives/subjects/
└── 100610
└── gambling
└── first_level_design_spm_mat_file
├── block
│ └── SPM.mat
└── event
└── SPM.mat
However, in my case I would like the whole hierarchy to be swapped and this leaves me kind of with a Catch-22. With regexp_substitutions, I can only replace a regex with a string but I kind of need to replace ‘a regex with a regex’ so to say).
So for example for the first file this would be the first filepath:
output/derivatives/subjects/100610/gambling/first_level_design_spm_mat_file/_subject_id_100610/_design_type_block/SPM.mat.
And the logic would need to be: “Find first_level_design_spm_mat_file and replace it with whatever string comes after _design_type (and vice versa)”