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

Handle duplicated fieldmaps in interrupted session #123

Closed
mateuszpawlik opened this issue Feb 1, 2022 · 15 comments
Closed

Handle duplicated fieldmaps in interrupted session #123

mateuszpawlik opened this issue Feb 1, 2022 · 15 comments
Assignees
Labels
enhancement New feature or request

Comments

@mateuszpawlik
Copy link

General summary

I'm trying to develop an end-to-end solution for handling duplicated fieldmaps in the case of interrupted sessions. I'm wandering what would be the best BIDScoin-based solution for that.

Additional detail

I briefly described the problem of interrupted sessions. The scenario is the following. The experiment consists of more than one functional scans, lets say task-1 and task-2. The fieldmaps are acquired. Some time after the first functional scan, the subject has to leave the scanner. Hence, the fieldmaps have to be acquired again after the return to the scanner. This leads to a situation when two sets of fieldmaps have to be kept, one for task-1 and another for task-2. The names of fieldmaps scans are not modified on the scanner.

The interruption is not consistent among subjects and, in case of multiple functional scans, can happen anytime. Using automatic run- indexes lets us differentiate the fieldmaps. However, this is applied to fieldmaps of all subjects, even if some subjects do not have duplicates. Moreover, if duplicated fieldmaps are not intended for specific scans consistently, this needs to be done manually.

Next steps

  • No steps at the moment.
@marcelzwiers
Copy link
Collaborator

Mhhh, this requires a bit of logic on top of the glob() search approach. But it's a fair point, I'll see what I can do

@marcelzwiers marcelzwiers self-assigned this Feb 1, 2022
@marcelzwiers marcelzwiers added the enhancement New feature or request label Feb 1, 2022
@mateuszpawlik
Copy link
Author

A viable consistent solution, but I'm not sure if within the scope of BIDScoin, could be the following. The fieldmaps are intended for any task that is acquired after them but before another filedmaps, if they're present, and so on.

@marcelzwiers
Copy link
Collaborator

I am thinking of extending the bidsmap language a bit, e.g. with a colon-separated slicing term:

IntendedFor: <<taskname:[-1]>>

This would select the last task run only

IntendedFor: <<taskname:[-2:]>>

would select the last two runs

IntendedFor: <<taskname:[0:3]>>

would select the first two runs

@marcelzwiers
Copy link
Collaborator

marcelzwiers commented Feb 1, 2022

But this doesn't solve your problem. It needs to be relative to the seriesnumber of the fieldmap. Implementing that is a bit more complicated

@mateuszpawlik
Copy link
Author

Thanks for a quick feedback. I think, that is exactly the problem. I'll sleep over it :-)

@marcelzwiers
Copy link
Collaborator

It's a bit convoluted to implement, but the problem at hand is a bit convoluted, so there is no way around it I think. I am currently thinking of:

IntendedFor: <<taskname:[-4:0]>>

Select maximally four preceding 'taskname' runs until a fieldmap with the same name but with a smaller run index

IntendedFor: <<taskname:[0:3]>>

Select maximally three subsequent 'taskname' runs until a fieldmap with the same name but with a larger run index

IntendedFor: <<taskname:[-2:2]>>

Select maximally two preceeding/subsequent 'taskname' runs until a fieldmap with the same name but with a smaller or larger run index

@marcelzwiers
Copy link
Collaborator

I implemented the above, but haven't tested it, could you perhaps give it a try?

@mateuszpawlik
Copy link
Author

Wow! Thank you :-) I knew it wasn't trivial to do and haven't expected any implementation. I'm more than happy to test it. But I may not be done today.

@mateuszpawlik
Copy link
Author

mateuszpawlik commented Feb 2, 2022

It seems to work on one example but let me do more testing and look at the code. I'd also like to understand better your solution because it is very general.

@marcelzwiers
Copy link
Collaborator

I actually thought about making it even more general, such as allowing for using json data to select files, e.g. <<IntendedFor:{EchoTime: 40}>>. I can still do that if needed, but the IntendedFor system is going to change in future BIDS versions, so I thought to keep it a bit more simple till then

@mateuszpawlik
Copy link
Author

mateuszpawlik commented Feb 3, 2022

but the IntendedFor system is going to change in future BIDS versions

Could you point me to any information about it? Is it this project?

@marcelzwiers
Copy link
Collaborator

I saw discussions on various places, e.g.:
bids-standard/bids-specification#622
bids-standard/bids-specification#718

@mateuszpawlik
Copy link
Author

I've started working on a script to generate DICOM files. I finally need some dummy data to test BIDS conversion. The important part is that dcm2niix can process the generated files without complaining too much. Once I'm done, I'll generate a few cases, test the interrupted sessions and come back here.

@mateuszpawlik
Copy link
Author

mateuszpawlik commented Feb 14, 2022

I've generated DICOMs for three subjects with DICOM generator and the following three configurations. I paste them at the end of the comment because GitHub doesn't support uploading JSON files here.

Dealing with the interrupted sessions works as expected with run: <<1>> and IntendedFor: <<task:[0:3]>> for the fmap section in the bidsmap file.

I tested it for the commit 0b7f3ef. The HEAD commit 7ae1f58 fails - see #127.

sub-1:

[
  {
    "ImageType" : "anat",
    "SeriesDescription" : "T1w"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri1"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri2"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri3"
  }
]

sub-2:

[
  {
    "ImageType" : "anat",
    "SeriesDescription" : "T1w"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri1"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri2"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri3"
  }
]

sub-3:

[
  {
    "ImageType" : "anat",
    "SeriesDescription" : "T1w"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri1"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri2"
  },
  {
    "ImageType" : "magnitude",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "phase",
    "SeriesDescription" : "fmap"
  },
  {
    "ImageType" : "fmri",
    "SeriesDescription" : "fmri3"
  }
]

@mateuszpawlik
Copy link
Author

I've tested it again with the commit 546d14a and it works as expected. Shall we close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants