Skip to content

MATLAB script for parsing DCM files to convert its data into a map of key-value pairs

License

Notifications You must be signed in to change notification settings

ks-santosh/Matlab-DCM-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matlab-DCM-Parser

The DcmParser m-script reads the DCM file and convert its data into a containers.Map object. This object retains DCM metadata, comments, and data order for reproducing DCM file from the object using MapToDcm m-script. Ensure the DCM file conforms to the specifications outlined in DCM_File_Formats.

There are additional DCM helper m-scripts that utilize the DcmParser library. Add the DcmParser folder to the MATLAB path to use them. Each helper script resides in its own folder and includes both a test DCM file and the corresponding output generated by the m-script.

Demo

Parsing DCM TestDCM.dcm

>> DcmVarMap = DcmParser('TestDCM.dcm');
START
-> Reading TestDCM.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 7
END 

Creating DCM file from containers.Map object

>> MapToDcm(DcmVarMap)
START
-> Creating DCM MapToDcm.DCM ...
-> Successfully created MapToDcm.DCM!
END 

Using CompareDcm.m to compare TestDCM1.dcm and TestDCM2.dcm. The result is stored in DcmComparisonRecord.xls

>> CompareDcm
#############  DCM Comparison #############
-> Select First DCM
-> DCM selected : TestDCM1.dcm
-> Select Second DCM
-> DCM selected : TestDCM2.dcm
START
-> Reading TestDCM1.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 6
END 
START
-> Reading TestDCM2.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 6
END 
-> Starting DCM Comparison...
-> Creating Excel DCM Mismatch Records in Current Folder...
-> Records written to : DcmComparisonRecord.xls
-> DCM Comparison Successfull!
#############  DCM Comparison End #############

The DcmToMScript.m converts DCM file to m-script to load the variables in the MATLAB workspace.

>> DcmToMScript
#############  DCM to M-Script #############
-> Select DCM
-> DCM selected : TestDCM.dcm
START
-> Reading TestDCM.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 7
END 
-> Created M-Script TestDCM.m
-> Load TestDCM.m to workspace
-> Successfully Converted DCM to M-Script
############# DCM to M-Script End #############

SplitDcm creates seperate DCM files for each FUNKTION.

>> SplitDcm
#############  Split DCM #############
-> Select Project DCM
-> Project DCM selected : TestDCM.dcm
START
-> Reading TestDCM.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 7
END 
START
-> Creating DCM BrakeFunc.DCM ...
-> Successfully created BrakeFunc.DCM!
END 
-> Created BrakeFunc.DCM
START
-> Creating DCM NA.DCM ...
-> Successfully created NA.DCM!
END 
-> Created NA.DCM
START
-> Creating DCM TempFunc.DCM ...
-> Successfully created TempFunc.DCM!
END 
-> Created TempFunc.DCM
START
-> Creating DCM TorqFunc.DCM ...
-> Successfully created TorqFunc.DCM!
END 
-> Created TorqFunc.DCM
-> Functional DCMs Kept here: DCM Files
-> Successfully Created Functional DCMs 
#############  Split DCM End #############

The log shows the ouput after parsing TestDCM.dcm

>> DcmVarMap = DcmParser('TestDCM.dcm');
START
-> Reading TestDCM.dcm ...
-> Successfully parsed DCM!
-> Number of variables read: 7
END 
>> DcmVarMap('Start')

ans =

  1×19 cell array

  Columns 1 through 4

    {'* DAMOS format'}    {'* Created by AS…'}    {'* Creation date…'}    {'*'}

  Columns 5 through 7

    {'* DamosDataFile…'}    {'* DamosExtensio…'}    {'* DamosFormatVe…'}

  Columns 8 through 10

    {'* DamosCaseSens…'}    {'* DamosIncludeB…'}    {'* DamosIncludeD…'}

  Columns 11 through 13

    {'* DamosBooleanF…'}    {'* DamosEnumerat…'}    {'* DamosShowInpu…'}

  Columns 14 through 17

    {'* DamosInputLog…'}    {'* DamosShowOutp…'}    {'* DamosOutputLo…'}    {0×0 char}

  Columns 18 through 19

    {'KONSERVIERUNG_F…'}    {0×0 char}

>> DcmVarMap('Order')

ans =

  1×8 cell array

  Columns 1 through 6

    {'Start'}    {'array'}    {'cont'}    {'distrib'}    {'One_D_group'}    {'sdisc'}

  Columns 7 through 8

    {'Two_D_group'}    {'udisc_1'}

>> DcmVarMap('array')

ans =

  1×7 cell array

  Columns 1 through 6

    {'FESTWERTEBLOCK'}    {[4]}    {'sample temperat…'}    {'NA'}    {'NA'}    {'° C'}

  Column 7

    {1×4 cell}

>> Temp = DcmVarMap('Two_D_group')

Temp =

  1×14 cell array

  Columns 1 through 6

    {'GRUPPENKENNFELD'}    {[3]}    {[3]}    {'engine calibrat…'}    {'NA'}    {'NA'}

  Columns 7 through 11

    {'A'}    {'m/s'}    {'Nm'}    {'distrib\Module_…'}    {'distrib\Module_…'}

  Columns 12 through 14

    {1×3 cell}    {1×3 cell}    {3×3 cell}

>> Temp(end)

ans =

  1×1 cell array

    {3×3 cell}

>> Temp{end}

ans =

  3×3 cell array

    {'1.0'}    {'2.0'}    {'3.0'}
    {'2.0'}    {'4.0'}    {'6.0'}
    {'3.0'}    {'6.0'}    {'9.0'}

>> Temp{end-1}

ans =

  1×3 cell array

    {'1.0'}    {'2.0'}    {'3.0'}

>> Temp{end-2}

ans =

  1×3 cell array

    {'1.0'}    {'2.0'}    {'3.0'}

>> 

About

MATLAB script for parsing DCM files to convert its data into a map of key-value pairs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages