Dcm2Bids
Dcm2Bids copied to clipboard
[ENH][WIP] Add a new customLabel feature using dcmTags for all acquisitions
This PR is usefull when you have a lot of tasks and to make it work you have to have a description for each task. It won't be used for filtering but for naming the output file, the same kind of way customLabel is working.
Now you can simply add:
"dcmTagLabel": {
"dcmTag": "SeriesDescription",
"expression": [".*(task-[0-9a-zA-Z]*).*",
".*(run-[0-9]*).*"]
},
"descriptions": [
{
"dataType": "func",
"modalityLabel": "bold",
"criteria": {
"SeriesDescription": "*task*"
}
}
instead of
"descriptions": [
{
"dataType": "func",
"modalityLabel": "bold",
"customLabel": "task-learning",
"criteria": {
"SeriesDescription": "*task-learning*"
}
},
{
"dataType": "func",
"modalityLabel": "bold",
"customLabel": "task-movie",
"criteria": {
"SeriesDescription": "*task-movie*"
}
},
{
"dataType": "func",
"modalityLabel": "bold",
"customLabel": "task-memory"_run-1,
"criteria": {
"SeriesDescription": "*task-memory*run-1*"
},
{
"dataType": "func",
"modalityLabel": "bold",
"customLabel": "task-memory"_run-2,
"criteria": {
"SeriesDescription": "*task-memory*run-2*"
}
}
Using this generic way, I had to re-define the way IntendedFor was working. Hope this new feature will help to have cleaner config files.
From what I understand, it can only extract information from a single dicom tag. Would it be possible to make it generalize to extract from multiple tags.
The most flexible way, would be to use regexp named capture groups, then being able to reinject the captured variables in the customLabels.
something like
"extractors" : {
"SeriesDescription": "task-(?P<task>[a-zA-Z0-9]+)_run-(?P<run>[0-9]+)",
"BodyPartExamined": "(?P<bodypart>[a-zA-Z]+)"
},
"descriptions": [
{
"dataType": "func",
"modalityLabel": "bold",
"customLabel": "task-\g<task>_run-\g<run>",
"criteria": {
"SeriesDescription": "func.*"
}
},
{
"dataType": "anat",
"modalityLabel": "T1w",
"customLabel": "bp-\g<bodypart>",
"criteria": {
"SeriesDescription": ".*T1w"
}
},
]
New PR #208