Donders-Institute / bidscoin

BIDScoin converts your source-level neuroimaging data to BIDS
https://bidscoin.readthedocs.io
GNU General Public License v3.0
131 stars 35 forks source link

bidscoiner with -session option #204

Closed karl-koschutnig closed 1 year ago

karl-koschutnig commented 1 year ago

Hi Marcel,

Could you help us with an additional flag in the bidscoiner command?

We are trying to build an automatic pipeline to convert our dcms into the bids. The heart of the conversion is your bidscoiner!! Now we want to implement the conversion process using nextflow. There is an (internal) specific way for handling folders within nextflow, which makes it tricky to move or change folders. Therefore, it would be great if you could add a session flag to the bidscoiner command (because we are not able to make a session-subfolder for each subject ;-(

something like this would be perfect: bidscoiner sourcedata bidscoiner -b bidsmap.yaml -p sub-001 -s ses-01

Thanks a lot Best, Karl

marcelzwiers commented 1 year ago

I see, I think that should be no problem, I'll have a look. Sounds great, your dataflow pipeline. FYI, our dataflow here is automated to a bids-like DICOM repository, as described here: https://github.com/Donders-Institute/dicom-dataflow

marcelzwiers commented 1 year ago

Before I implement a -session option, let me make sure that I get this right. So from this sourcefolder:

raw/
├── sub-001
│   └── ses-01
│   └── ses-02
└── sub-002
    └── ses-01

you want to convert, let's say, only raw/sub-001/ses-02 to bids/sub-001/ses-02, using this command, right? bidscoiner raw bids --participant_label 001 --session_label 02

marcelzwiers commented 1 year ago

Alternatively, I can also implement a (more flexible) combined sub/ses label:

bidscoiner raw bids --participant_label sub-001/ses-02 sub-002/ses-01
karl-koschutnig commented 1 year ago

So, the problem is that we don't have a session subfolder at all. We have a certain way to name our participants: studyid_group_session_participantnumber. So, the session is present in each participant-code. Within nextflow we get the participant-code folder (from dicomsort), but we have to provide a session-subfolder for the coining, right?

Here is a dummy structure after dicomsort (we use DICOMDIR as input) sub-XXYY_1_1_001 (studyID XXYY, group = 1, session = 1, participant_nr = 001)

We would like to split the study id code and prove the session to bidscoiner. I guess the second option you mentioned would be perfect!

Thanks

marcelzwiers commented 1 year ago

What should already work (but I didn't test this) is to have raw data in a subject folder (i.e. without a session folder) and then in the bidsmap specify the session output folder, e.g. like this: {session: <<StudyID>>}. Would that work for you? So:

raw/
├─ sub-001
│   └── SeriesNumber-SeriesDescription
│   └── [..]
└── sub-002
    └── [..]

For {StudyID: 01} data in raw/sub-00* this should then become:

bids/
├── sub-001
│   └── ses-01
└── sub-002
    └── ses-01
karl-koschutnig commented 1 year ago

That sounds great to me. However, I am not sure how I can define different sessions. For cross-sections studies, I see no problem. But with longitudinal data, how am I suppose to get the session-ID in the bids map. Is there a way to "dynamically" split the StudyID. Sorry for all the questions!! Maybe there is an easy regular expression to deal with our problem?!

marcelzwiers commented 1 year ago

So you want bids sessions, right? Where/ how is your bids session label stored (before conversion)?

karl-koschutnig commented 1 year ago

Yes, that's right - we want to provide a session within the BIDS for each participant. As I tried to explain, the session ID is part of the subject-code (entered at the scanner).

marcelzwiers commented 1 year ago

So it is in the DICOM header, in the PatientComments field? In that case, you would put something like {session: <<PatientComments: sub-.*?ses-(.*?)>>} in the bidsmap.

marcelzwiers commented 1 year ago

Can you give an example of what is entered at the scanner?

marcelzwiers commented 1 year ago

(you can apply the same for the subject label btw)

marcelzwiers commented 1 year ago

(I think you don't even need to run dicomsort)

karl-koschutnig commented 1 year ago

Ok - that sounds great - I will try.

Here is an example of one subject-code entered at our scanner: 126_BP_CP02_1_1_091

StudyNr=126 ; BP=department; CP02=principle investigators; 1 = group; 1=session; 091=subject nr (ascending)

karl-koschutnig commented 1 year ago

BTW we could change the code if necessary in future studies. If you have any suggestions to filter out the session more easily - we would very much appreciate your input!!

karl-koschutnig commented 1 year ago

Hi Marcel, In the meantime, I could figure out how to define the sessions-folder within nextflow. Thanks again for the effort!!

I have another question that bothers me a little bit in our nextflow-pipeline. The idea behind nextflow is to chain together processes (output of A --> input B ....) in a more or less easy way (and in parallel). This only holds if the process before runs through cleanly. The problem is that the output of bidscoiner (sometimes) prompts warnings. These warnings are interpreted as errors in nextflow. So, is it possible to omit warning -messages in bidscoiner?

Thanks!

marcelzwiers commented 1 year ago

In the meantime, I could figure out how to define the sessions-folder within nextflow. Thanks again for the effort!!

Just for my curiosity, what is the regexp that you are using now?

I have another question that bothers me a little bit in our nextflow-pipeline. The idea behind nextflow is to chain together processes (output of A --> input B ....) in a more or less easy way (and in parallel). This only holds if the process before runs through cleanly. The problem is that the output of bidscoiner (sometimes) prompts warnings. These warnings are interpreted as errors in nextflow. So, is it possible to omit warning -messages in bidscoiner?

I cannot easily omit sending warnings to the logging systems, but I can set the logging level. But I suspect that is not going to help, and I need to understand how logging and nexflow interact (I wouldn't expecting any interaction actually). Can you provide more info on what triggers nextflow (some error/log messages or so)?

marcelzwiers commented 1 year ago

I am considering to release a new bidscoin version soon, so if you need anything or have any suggestions, let me know, then I can perhaps still include it in the release

karl-koschutnig commented 1 year ago

Marcel, that's really nice. Thank you! I am struggling a little bit with our server (there is no Xorg --> no Gui) at the moment. That's why I couldn't replicate my problems. I am goot for now - but thanks again for asking!!