Extraction of Slice Ordering in DICOM Image

Download Complete Package in Zip File

 

Slice ordering (SO) is set in a protocol for MR scan and the information is saved in DICOM image header. For example, Sagittal (R)ight >> (L)eft, Coronal (A)nterior >> (P)osterior, Transverse (F)oot >> (H)ead. The released software, checkslice reads the slice order direction from a DICOM file, and the MATLAB script provides an idea of how to check SO from EPI data of multiple projects and studies. The releases were tested with CentOS and Ubuntu. If a bug is found, please report to Dr. Moon, moonc@upmc.edu.

 

 

Download “Release.zip” and unzip it on your computer disc. The unzipped folders and files are,

PhantData/

            BOLDSLICEORDER_mMR/ (the sequence name includes transverse SO, ex, HF. If none, it is FH)

            BOLDSLICEORDER_Prisma1/ (the sequence name includes transverse SO, ex, FH or HF)

            checkslice.m

            …

checkslice (under different Linux OS)

ReadMe.docx

 

1. checkslice binary

 

Description:     Ubuntu 16.04.7 LTS

Release:          16.04

Codename:      xenial

 

Description:     Ubuntu 18.04.5 LTS

Release:          18.04

Codename:      bionic

 

centos-release-8.2-2.2004.0.1.el8.x86_64

 

Requirement of additional software: None

The path of checkslice should be visible to a user, for example, /usr/local/bin/checkslice

 

  1. Download the binary file checkslice
  2. Type checkslice in command line for help

    This program extract Slice ordering from DICOM file!

    Usage : checkslice -i dicom.ima -sd [0/1/2] -so [0/1] @chm, 02/18/2021

            -i dicom.ima: Siemens DICOM file

            -sd [0/1/2]: Slice direction 0-sag, 1-cor, 2-tra, other – all(default)

            -so [0/1]: Slice ordering (MB=1) 1-yes print, 0-no print(default)

  3. Type checkslice -i dicomfile …

 

Examples,

 

checkslice -i BOLDSLICEORDER.IMA

Slice Sagittal direction is R >> L (if image slice is sagittal)

Slice Coronal direction is A >> P (if image slice is coronal)

Slice Transverse direction is H >> F (if image slice is transverse)

 

checkslice -i BOLDSLICEORDER.IMA -sd 2

H >> F

 

checkslice -i BOLDSLICEORDER.IMA -sd 3 -so 1

Slice Sagittal direction is R >> L

Slice Coronal direction is A >> P

Slice Transverse direction is H >> F

Slice ordering is INTERLEAVED 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44

 

2. MATLAB script, checkslice.m

 

% MATLAB script to read Slice ordering in EPI DICOM image

%

% 02/26/2021, Chan Hong Moon, PhD

%

% Add path for necessary m codes

addpath('/your_matlab_script_folder_path/PhantData');

% Set your study folder path for EPI DICOM

pfolderlist = {...

    '/your_study_folder_path/PhantData/BOLDSLICEORDER_mMR'...

    '/your_study_folder_path/PhantData/BOLDSLICEORDER_Prisma1'...

};

npfolderlist = length(pfolderlist);

% Sequence naming

EPInamelist = {...

    '*EP2D_*'...

    '*BOLD*'...

};

nepilist = length(EPInamelist);

% Loop for slice ordering

lcount = 1;

for ll=1:npfolderlist

    pfolder = pfolderlist{1,ll};

    fprintf(2,'%s\n', pfolder);

    Pfolder = [pfolder '/'];

    icheck = 0;

    for i=1:nepilist

        if icheck>=1

            break;

        end

        episeqname = EPInamelist{1,i};

        direpiBOLD = dir([Pfolder episeqname]);

        lcount = 1;

        nepiBOLD = length(direpiBOLD);

        for k=1:nepiBOLD,

            epiBOLD = direpiBOLD(k,1).name;

            P = [pfolder '/' epiBOLD '/'];

            dirdicom = dir([P '*.IMA']);

            if (isempty(dirdicom))

                dirdicom = dir([P 'MR.*']);

            end

            nfiles = length(dirdicom);

            % read DICOM header including CSA information

            [dcminfo, err] = dicm_hdr([dirdicom(1).folder '/' dirdicom(1).name]);

            % checkslice in terminal

            dicomfilename = [dirdicom(1).folder '/' dirdicom(1).name];

            strcmd = ['checkslice -i ' dicomfilename ' -sd 2'];

            [s,w] = unix(strcmd);

            I = find(w~=' ');

            w = w(I); w=w(1:end-1);

            % report

            disp([num2str(lcount) ': ' epiBOLD ': ' w(1:end)]);

            lcount = lcount + 1;

            icheck = 1;

        end

    end

end

% rm path for necessary m codes

rmpath('/ your_matlab_script_folder_path/PhantData');

 

Outputs are like as follows,

 

 

>> checkslice

/your_study_folder_path/PhantData/BOLDSLICEORDER_mMR

1: EP2D_BOLD_MB1_SLC45_0002: F>>H

2: EP2D_BOLD_MB1_SLC45_ASC_0015: F>>H

3: EP2D_BOLD_MB1_SLC45_DSC_0016: F>>H

4: EP2D_BOLD_MB1_SLC46_0003: F>>H

5: EP2D_BOLD_MB1_SLC46_HF_0004: H>>F

6: EP2D_BOLD_MB2_SLC46_0008: F>>H

7: EP2D_BOLD_MB2_SLC46_SBREF_0007: F>>H

8: EP2D_BOLD_MB3_SLC45_0006: F>>H

9: EP2D_BOLD_MB3_SLC45_SBREF_0005: F>>H

10: EP2D_BOLD_MB3_SLC48_0012: F>>H

11: EP2D_BOLD_MB3_SLC48_HF_0014: H>>F

12: EP2D_BOLD_MB3_SLC48_HF_SBREF_0013: H>>F

13: EP2D_BOLD_MB3_SLC48_SBREF_0011: F>>H

14: EP2D_BOLD_MB4_SLC48_0010: F>>H

15: EP2D_BOLD_MB4_SLC48_SBREF_0009: F>>H

/ your_study_folder_path/PhantData/BOLDSLICEORDER_Prisma1

1: CMRR_BOLD_AP_MB1_46SLC_FH_0002: F>>H

2: CMRR_BOLD_AP_MB1_46SLC_HF_0003: H>>F

3: CMRR_BOLD_AP_MB3_48SLC_FH_0009: F>>H

4: CMRR_BOLD_AP_MB3_48SLC_FH_SBREF_0008: F>>H

5: CMRR_BOLD_AP_MB3_48SLC_HF_0011: H>>F

6: CMRR_BOLD_AP_MB3_48SLC_HF_SBREF_0010: H>>F

7: CMRR_BOLD_AP_MB4_48SLC_FH_0005: F>>H

8: CMRR_BOLD_AP_MB4_48SLC_FH_SBREF_0004: F>>H

9: CMRR_BOLD_AP_MB4_48SLC_HF_0007: H>>F

10: CMRR_BOLD_AP_MB4_48SLC_HF_SBREF_0006: H>>F

11: MGH_BOLD_AP_MB1_46SLC_FH_0012: F>>H

12: MGH_BOLD_AP_MB1_46SLC_FH_PMU_0013: F>>H

13: MGH_BOLD_AP_MB1_46SLC_HF_0014: H>>F

14: MGH_BOLD_AP_MB1_46SLC_HF_PMU_0015: H>>F

15: MGH_BOLD_AP_MB3_48SLC_FH_0020: F>>H

16: MGH_BOLD_AP_MB3_48SLC_FH_PMU_0021: F>>H

17: MGH_BOLD_AP_MB3_48SLC_HF_0022: H>>F

18: MGH_BOLD_AP_MB3_48SLC_HF_PMU_0023: H>>F

19: MGH_BOLD_AP_MB4_48SLC_FH_0016: F>>H

20: MGH_BOLD_AP_MB4_48SLC_FH_PMU_0017: F>>H

21: MGH_BOLD_AP_MB4_48SLC_HF_0018: H>>F

22: MGH_BOLD_AP_MB4_48SLC_HF_PMU_0019: H>>F

23: SIEMENS_BOLD_AP_MB1_46SLC_FH_0024: F>>H

24: SIEMENS_BOLD_AP_MB1_46SLC_HF_0025: H>>F

25: SIEMENS_BOLD_AP_MB3_48SLC_FH_0028: F>>H

26: SIEMENS_BOLD_AP_MB3_48SLC_HF_0029: H>>F

27: SIEMENS_BOLD_AP_MB4_48SLC_FH_0026: F>>H

28: SIEMENS_BOLD_AP_MB4_48SLC_HF_0027: H>>F