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

dcm2bids_config -"intendedFor": 0- writes the reference file path without session number #67

Closed
agriffa opened this issue Sep 10, 2019 · 8 comments
Labels

Comments

@agriffa
Copy link

agriffa commented Sep 10, 2019

Hello!

I'm running dcm2bids on a set of fMRI and fieldmap data.
I would like to refer the fieldmap data to the fMRI acquisition.
I therefore use the option "intendedFor" in the dcm2bids_config.json file (pasted below).

After running dcm2bids on my data, the fieldmap json contains the following line:
"IntendedFor": "func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz",
which gives an error in the online bids validator:
Error 1: [Code 37] INTENDED_FOR.
'IntendedFor' property of this fieldmap does not point to an existing file'.

Modifying the fieldmap json with the following line corrects the bids validator error:
"IntendedFor": "ses-01/func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz".

Is there a problem with how dcm2bids handles the "intendedFor" option, or am I missing some fundamental step?

Thank you very much for your help and work!
I hope I am posting this issue in the right place.

Best regards,
Alessandra

My dcm2bids_config.json file looks like this:

{
"searchMethod": "fnmatch",
"defaceTpl": "pydeface --outfile {dstFile} {srcFile}",
"descriptions": [
{
"dataType": "func",
"modalityLabel": "bold",
"customLabels": "task-rest7min",
"criteria": {
"SeriesDescription": "cmrr_mbep2d_bold_tr1000"
},
},
{
"dataType": "fmap",
"modalityLabel": "phasediff",
"criteria": {
"SeriesDescription": "gre_field_mapping",
"SeriesNumber": 7
},
"sidecarChanges": {
"EchoTime1": 0.00449,
"EchoTime2": 0.00695
},
"intendedFor": 0
}
]
}

@dlevitas
Copy link

Hi @agriffa ,

The intendedFor field needs an explicit path to the file from inside the sub-HPNC040 directory. Since your data contains ses-01, the "full path" required by the intendedFor field in your .json file is what your modified ("ses-01/func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz"). If your data did not contain a ses-01, then the intendedFor field would be "func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz".

One other thing. Are you sure that task-rest7min is BIDS compliant? Usually when I see resting-state data, it's just task-rest. But if you're not getting validation errors then I guess it's fine.

@agriffa
Copy link
Author

agriffa commented Sep 16, 2019

Dear @dlevitas ,

Thank you very much for your answer!

I understand that the intendedFor field requires the "full path".

My problem is that if I specify "intendedFor": 0 in my dcm2bids_config file, where the first series ('0') is the func acquisition, dcm2bids will write a wrong path in the .json file. The call
dcm2bids -d /path/to/dicom/files/ -p HPNC040 -s 01 -c /path/to/dcm2bids_config.json -o /bids/folder/
writes
"IntendedFor": "func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz"
instead of
"IntendedFor": "ses-01/func/sub-HPNC040_ses-01_task-rest7min_bold.nii.gz"
in the .json file associated to the fieldmap Nifti.
Is there a way to automatically get the prefix ses-01 in the .json file, while using "intendedFor": 0 in dcm2bids_config?

I don't get errors or warnings from the bids-validator when using task-rest7min.

@dlevitas
Copy link

dlevitas commented Sep 16, 2019

Got it, sorry for the misunderstanding. Are you using the most current version of dcm2bids (2.1.4)? This was an issue in earlier versions, but in the newest version it should be resolved.

@agriffa
Copy link
Author

agriffa commented Sep 16, 2019

Yes, I do have dcm2bids v2.1.4

pip install --upgrade dcm2bids
Requirement already up-to-date: dcm2bids in /anaconda3/lib/python3.7/site-packages (2.1.4)

I can try to git clone dcm2bids and reinstall.

@agriffa
Copy link
Author

agriffa commented Sep 16, 2019

After git clone dcm2bids and reinstall, everything work. Thank you for your help!

@SamGuay
Copy link
Member

SamGuay commented Aug 14, 2020

Thanks so much for opening this issue @agriffa. I couldn't get why I was getting this problem until I found your issue. After many attempts at validating my files, I found out that if someone pip install dcm2bids, it seems that it doesn't come with the #52 patch even though it was merged a while ago. So I was always getting the "IntendedFor" error.

Maybe #81 should be reviewed/merged to make sure it doesn't happen?

To validate my hypothesis, I freshly installed dcm2bids on my local computer in a virtual env and looked into the structure.py to find the missing code.

Here's what I found: I couldn't find these last 2 lines from the master branch.

                session = self.participant.session
                        opj(session, dataType, niiFile).replace("\\", "/"))
(dcm2bids) sam@FX:~/$: pip install dcm2bids
Collecting dcm2bids
  Downloading dcm2bids-2.1.4-py2.py3-none-any.whl (28 kB)
Collecting future
  Downloading future-0.18.2.tar.gz (829 kB)
     |████████████████████████████████| 829 kB 3.4 MB/s 
Using legacy setup.py install for future, since package 'wheel' is not installed.
Installing collected packages: future, dcm2bids
    Running setup.py install for future ... done
Successfully installed dcm2bids-2.1.4 future-0.18.2

(dcm2bids) sam@FX:~$ grep "session" /home/sam/.pyenv/versions/dcm2bids/lib/python3.7/site-packages/dcm2bids/structure.py
        session (str): Optional label of a session
    def __init__(self, name, session=DEFAULT.session):
        self._session = ""
        self.session = session
    def session(self):
            A string 'ses-<session_label>'
        return self._session
    @session.setter
    def session(self, session):
        if session.strip() == "":
            self._session = ""
        elif session.startswith("ses-"):
            self._session = session
            self._session = "ses-" + session
            'sub-<subject_label>/ses-<session_label>'
            return opj(self.name, self.session)
            'sub-<subject_label>_ses-<session_label>'
            return self.name + "_" + self.session
        """ Check if a session is set
        return not self.session.strip() == DEFAULT.session
(dcm2bids) sam@FX:~$ 

@arnaudbore
Copy link
Contributor

@SamGuay is still the case with v2.1.5 or #107 ?

@arnaudbore arnaudbore added the bug label Jan 22, 2021
@SamGuay
Copy link
Member

SamGuay commented Jan 22, 2021

Just installed it in a fresh venv and it seems to be there!

        return self.session.strip() != DEFAULT.session
                session = self.participant.session
                intendedValue.append(opj(session, dataType, niiFile).replace("\\", "/"))

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

No branches or pull requests

4 participants