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

Fix space other use and correct json sidecars #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NathanMolinier
Copy link
Contributor

@NathanMolinier NathanMolinier commented Jul 2, 2024

Description

⚠️ This PR only affects the derivative folder label as well as some raw images

This PR fixes:

  • miss usage of the BIDS entity space-other
  • incorrect format of JSON sidecars

introduced in this former PR.

Miss use of the BIDS entity space-other

The entity space-XXX should only be used on a label if the space of the latter is different from the one of the corresponding image (see our documentation).

To fix this, I iterated through all the labels in the derivative folder labels with the space-other entity using this script:

  • the entity space-other was removed from the label and the corresponding json sidecar if the array size was the same as the corresponding raw image.

  • the entity space-other was moved after the first suffix for the label and the corresponding json sidecar if the array size was different between the raw image and the label. (e.g. labels were renamed from sub-subject001_space-other_T1w_label-SC_seg.nii.gz --> sub-subject001_T1w_space-other_label-SC_seg.nii.gz)

Potential underlying problem

In this PR , it looks like all the T1w images were resampled to 1mm3, all the T2w images were resampled to 0.8mm3... without considering the resolution of the raw image. Even though this was true for most of the labels, it is actually not true for some images.

/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-beijingGE01/anat/sub-beijingGE01_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-beijingGE02/anat/sub-beijingGE02_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-beijingGE03/anat/sub-beijingGE03_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-beijingGE04/anat/sub-beijingGE04_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb01/anat/sub-brnoUhb01_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb01/anat/sub-brnoUhb01_space-other_T1w_label-vertebrae_desc-C3C5_dlabel.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb01/anat/sub-brnoUhb01_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb02/anat/sub-brnoUhb02_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb02/anat/sub-brnoUhb02_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb03/anat/sub-brnoUhb03_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb03/anat/sub-brnoUhb03_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb04/anat/sub-brnoUhb04_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb04/anat/sub-brnoUhb04_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb05/anat/sub-brnoUhb05_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb05/anat/sub-brnoUhb05_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb06/anat/sub-brnoUhb06_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb06/anat/sub-brnoUhb06_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb07/anat/sub-brnoUhb07_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb07/anat/sub-brnoUhb07_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb08/anat/sub-brnoUhb08_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb08/anat/sub-brnoUhb08_space-other_T1w_label-vertebrae_desc-C3C5_dlabel.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-brnoUhb08/anat/sub-brnoUhb08_space-other_T2w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-cmrra03/anat/sub-cmrra03_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-perform03/anat/sub-perform03_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w01/anat/sub-tokyo750w01_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w02/anat/sub-tokyo750w02_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w03/anat/sub-tokyo750w03_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w04/anat/sub-tokyo750w04_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w05/anat/sub-tokyo750w05_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w06/anat/sub-tokyo750w06_space-other_T1w_label-SC_seg.nii.gz
/Users/nathan/data/data-spinegeneric-fix/derivatives/labels/sub-tokyo750w07/anat/sub-tokyo750w07_space-other_T1w_label-SC_seg.nii.gz
  • all the raw images were saved using the RPI orientation.

Fixing JSON sidecars

JSON sidecars were modified as well to follow our convention. The script used is here.

Examples

Manual + Resampling (same space)

Before

{
    "Author": "Sandrine Bedard",
    "Date": "2021-07-25 13:39:39",
    "SpatialReference": {
        "Resampling": "1x1x1",
        "Reorientation": "RPI"
}

After

{
    "SpatialReference": "orig",
    "GeneratedBy": [
        {
            "Name": "Manual",
            "Author": "Sandrine Bedard",
            "Date": "2021-07-25 13:39:39"
        },
        {
            "Name": "sct_resample",
            "Flags": "-mm",
            "Resolution": "1x1x1",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        },
        {
            "Name": "sct_image",
            "Flags": "-setorient",
            "Orientation": "RPI",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        }
    ]
}
Manual + Root Mean Square (same space)

Before

{
    "Author": "Sandrine Bedard",
    "Date": "2021-06-08 15:05:54",
    "SpatialReference": {
        "Reorientation": "RPI",
        "Other": "root-mean square across 4th dimension (if it exists)"
}

After

{
    "SpatialReference": "orig",
    "GeneratedBy": [
        {
            "Name": "Manual",
            "Author": "Sandrine Bedard",
            "Date": "2021-06-08 15:05:54"
        },
        {
            "Name": "sct_maths",
            "Flags": "-rms",
            "Axis": "t",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        },
        {
            "Name": "sct_image",
            "Flags": "-setorient",
            "Orientation": "RPI",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        }
    ]
}
Manual + Resampling (different space)

Before

{
    "Author": "Etienne Bergeron",
    "Date": "2021-06-14 09:47:22",
    "SpatialReference": {
        "Resampling": "0.8x0.8x0.8",
        "Reorientation": "RPI"
}

After

{
    "SpatialReference": {
        "Resampling": "0.8x0.8x0.8",
        "Reorientation": "RPI"
    },
    "GeneratedBy": [
        {
            "Name": "Manual",
            "Author": "Etienne Bergeron",
            "Date": "2021-06-14 09:47:22"
        },
        {
            "Name": "sct_resample",
            "Flags": "-mm",
            "Resolution": "0.8x0.8x0.8",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        },
        {
            "Name": "sct_image",
            "Flags": "-setorient",
            "Orientation": "RPI",
            "Version": "SCT v6~",
            "Date": "2024-02-20 00:00:00"
        }
    ]
}

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

Successfully merging this pull request may close these issues.

2 participants