Slice Time and bids-validator problems with Philips scanner Dicoms

Dear Experts,

I’m currently trying to get my dataset ready for preprocessing with fmriprep.

I have 2 1/2 questions:

  1. As Philips scanner (multiband 2) output doesn’t seem to contain slice times I’m wondering if someone has a good workflow to deal with this? How did you calculate it and is there a way to add this information to the .json files without having to copy paste it for each single participant? Is there something else we have to adapt before running fmriprep that would otherwise influence data processing?
    Some have already posted about this issue here but I can’t seem to find a solution yet, if there is please direct me towards it =). Any input would be greatly appreciated.

  2. the bids validator gives the error:
    [ERR] You have to define 'TaskName' for this file. (code: 50 - TASK_NAME_MUST_DEFINE)
    I could fix that by adding a “TaskName” line to the json files corresponding to the functional scans. However, that is quite a tedious undertaking if we have to do it for each participant, is there a workaround?

  3. the bids validator gives the error (omitted sub numbers & we only have 1 run so didn’t specify that in the protocol_translator):
    `> 1: [ERR] Files with such naming scheme are not part of BIDS specification.
    ./sub-1006/DWI/sub-xxx_dwi-2d-revphase_run-01_DWI.json
    Evidence: sub-xxx_dwi-2d-revphase_run-01_DWI.json
    ./sub-1006/DWI/sub-xxx_dwi-2d-revphase_run-01_DWI.nii.gz
    Evidence: sub-xxx_dwi-2d-revphase_run-01_DWI.nii.gz
    ./sub-1006/DWI/sub-xx_run-01_DWI.json
    Evidence: sub-xxx_run-01_DWI.json
    ./sub-1006/DWI/sub-xxx_run-01_DWI.nii.gz
    Evidence: sub-xxx_run-01_DWI.nii.gz
    ./sub-1006/func/sub-xxx_run-01_task-rest.json
    Evidence: sub-xxx_run-01_task-rest.json
    ./sub-1006/func/sub-xxx_run-01_task-rest.nii.gz
    Evidence: sub-xxx_run-01_task-rest.nii.gz

We have tried changing the Protocol_Translator.json so many times in so many different ways without any luck of fixing this problem. Does anybody have a suggestion?

Thanks in advance and best wishes!

Philips DICOMs do not contain slice timing information. Therefore, details must be provided manually. You may want to look at the notes for Philips slice timing (though note that BIDS expects slice times in seconds).

You may want to leverage the Inheritance Principle to provide the slice timing information once for all your images.

@sandeepganji has been working on a tool that can extract Philips sequence information from the Philips ExamCard DICOMs (though these non-image files that are often not retained by PACS systems).

1 Like

It shouldn’t be too hard to code this. Using Python packages os and json, you can set up a loop to rename files and append to json files.

Few problems here:
1) dwi-2d-revphase is not a bids-compliant field. If you want that in your file name, you can do something like acq-revphase instead. Also these files seem like they are just reverse encoded fieldmaps, maybe they should go in fmap instead? BIDS apps like QSIPrep may otherwise try to process them as if they were a full 4D file.
2) DWI should be lowercase, in both the directory names and within the filenames (e.g. ....dwi.nii.gz)
3) The func files should end with bold.nii.gz/.json.

1 Like

If you have your original dicoms, you can try dcm2bids to go from dicoms to BIDS structure while avoiding the guesswork and tedium.

@Steven thanks for your reply. dcm2bids doesn’t solve the problems (i guess because of intrinsic philips scanner issues), and renaming the files still didn’t work, but followed your advice and hope it won’t generate problems in the future =)

Thanks to you both, I should be able to continue with the next steps now =)

I run a force update of the json files. heudiconv saves them read only.

#!/usr/bin/env python3
from bids import BIDSLayout
import json
import os
import stat
import glob
import nibabel as nib

layout = BIDSLayout('./nifti')
bold_files=layout.get( suffix='bold', task='lernmulti3', extension='nii.gz')
rest_files=layout.get( suffix='bold', task='restingstate', extension='nii.gz')

subjects = layout.get(return_type='id', target='subject' )
# Multiband 2, ascending, TR 2s
for epi_file in bold_files:
    epi = nib.load(epi_file)
    slices = epi.header['dim'][3]
    myjson=json.loads(json.dumps(epi_file.get_metadata()))
    myjson.update({'SliceTiming': [slicescantime * 2./slices for slicescantime in range(slices//2)]*2 })
    myjson.update({'PhaseEncodingDirection':'j-'})
    myjson.update({'EffectiveEchoSpacing':epi_file.tags['EstimatedEffectiveEchoSpacing'].value})
    os.chmod(epi_file.path.replace('.nii.gz', '.json'), stat.S_IWRITE | stat.S_IREAD | stat.S_IRGRP |     stat.S_IROTH )
    with open (epi_file.path.replace('.nii.gz', '.json'),'w') as jf:
      jf.write(json.dumps(myjson, indent=4))

# Standard epi, ascending, TR 2s
for epi_file in rest_files:
    epi = nib.load(epi_file)
    slices = epi.header['dim'][3]
    myjson=json.loads(json.dumps(epi_file.get_metadata()))
    myjson.update({'SliceTiming': [slicescantime * 2./slices for slicescantime in range(slices)] })
    myjson.update({'PhaseEncodingDirection':'j-'})
    myjson.update({'EffectiveEchoSpacing':epi_file.tags['EstimatedEffectiveEchoSpacing'].value})
    os.chmod(epi_file.path.replace('.nii.gz', '.json'), stat.S_IWRITE | stat.S_IREAD | stat.S_IRGRP |     stat.S_IROTH )
    with open (epi_file.path.replace('.nii.gz', '.json'),'w') as jf:
      jf.write(json.dumps(myjson, indent=4))
1 Like

dcm2bids uses whatever dcm2niix you have installed. Do you have the most recent dcm2niix? A lot of the recent updates improve Phillips compatibility. If you were not using the most recent version (and still need to address this problem), I would suggest upgrading and trying dcm2bids again.

yes I do, but from I understand there’s simply not all information present in the dicoms. thx for your continuing help =)! i’ve run fmriprep succesfully by now (only problem still is that i cannot use my HDD coz of readonly issues…working on that now…)

MANAGED BY INCF