Skip to content
Permalink
Browse files

updated for dcm4che3

  • Loading branch information...
adityaapte authored and aditiiyer committed Jul 5, 2019
1 parent 8bfd3ac commit 95b1cffbaeef9f02a89bc0b810df06ad7b240873
Showing with 2,696 additions and 1,546 deletions.
  1. +6 −0 CERR_core/CERROptions.json
  2. +2 −1 CERR_core/Importing/CERRImportDCM4CHE.m
  3. +19 −14 CERR_core/Importing/dicomrt-toolbox-v2/load/calc_suv.m
  4. +23 −1 CERR_core/Importing/initializeScanInfo.m
  5. +36 −33 ML_Dicom/Export/export_CT_IOD.m
  6. +51 −49 ML_Dicom/Export/export_RD_IOD.m
  7. +32 −30 ML_Dicom/Export/export_RS_IOD.m
  8. +14 −10 ML_Dicom/Export/export_module.m
  9. +27 −13 ML_Dicom/Export/export_sequence.m
  10. +27 −23 ML_Dicom/Export/modules/export_CT_image_module_field.m
  11. +9 −6 ML_Dicom/Export/modules/export_RT_DVH_module_field.m
  12. +6 −8 ML_Dicom/Export/modules/export_SOP_common_module_field.m
  13. +10 −3 ML_Dicom/Export/modules/export_frame_of_reference_module_field.m
  14. +6 −8 ML_Dicom/Export/modules/export_general_equipment_module_field.m
  15. +3 −2 ML_Dicom/Export/modules/export_general_image_module_field.m
  16. +14 −11 ML_Dicom/Export/modules/export_general_series_module_field.m
  17. +27 −8 ML_Dicom/Export/modules/export_general_study_module_field.m
  18. +10 −16 ML_Dicom/Export/modules/export_image_pixel_module_field.m
  19. +6 −8 ML_Dicom/Export/modules/export_image_plane_module_field.m
  20. +4 −4 ML_Dicom/Export/modules/export_multi_frame_module_field.m
  21. +37 −22 ML_Dicom/Export/modules/export_patient_module_field.m
  22. +12 −7 ML_Dicom/Export/modules/export_roi_contour_module_field.m
  23. +20 −28 ML_Dicom/Export/modules/export_rt_dose_module_field.m
  24. +10 −5 ML_Dicom/Export/modules/export_rt_roi_observations_module_field.m
  25. +16 −9 ML_Dicom/Export/modules/export_rt_series_module_field.m
  26. +19 −16 ML_Dicom/Export/modules/export_structure_set_module_field.m
  27. +3 −2 ML_Dicom/Export/sequences/export_DVH_referenced_ROI_sequence.m
  28. +9 −14 ML_Dicom/Export/sequences/export_DVH_sequence.m
  29. +13 −9 ML_Dicom/Export/sequences/export_ROI_contour_sequence.m
  30. +4 −4 ML_Dicom/Export/sequences/export_contour_image_sequence.m
  31. +33 −11 ML_Dicom/Export/sequences/export_contour_sequence.m
  32. +12 −8 ML_Dicom/Export/sequences/export_referenced_frame_of_reference_sequence.m
  33. +4 −4 ML_Dicom/Export/sequences/export_referenced_rt_plan_sequence.m
  34. +5 −5 ML_Dicom/Export/sequences/export_referenced_structure_set_sequence.m
  35. +12 −6 ML_Dicom/Export/sequences/export_rt_referenced_series_sequence.m
  36. +11 −10 ML_Dicom/Export/sequences/export_rt_referenced_study_sequence.m
  37. +9 −8 ML_Dicom/Export/sequences/export_rt_roi_observations_sequence.m
  38. +9 −7 ML_Dicom/Export/sequences/export_structure_set_ROI_sequence.m
  39. +3 −2 ML_Dicom/Export/sequences/export_structure_set_referenced_series_sequence.m
  40. +57 −21 ML_Dicom/Import/dcmdir2planC.m
  41. +7 −1 ML_Dicom/Import/getTest_Scan_IOP.m
  42. +16 −13 ML_Dicom/Import/populate_planC_DVH_field.m
  43. +19 −25 ML_Dicom/Import/populate_planC_USscan_field.m
  44. +70 −40 ML_Dicom/Import/populate_planC_USscan_scanInfo_field.m
  45. +2 −3 ML_Dicom/Import/populate_planC_beamGeometry_field.m
  46. +35 −27 ML_Dicom/Import/populate_planC_beams_field.m
  47. +82 −77 ML_Dicom/Import/populate_planC_dose_field.m
  48. +76 −31 ML_Dicom/Import/populate_planC_field.m
  49. +50 −34 ML_Dicom/Import/populate_planC_gsps_field.m
  50. +1 −1 ML_Dicom/Import/populate_planC_header_field.m
  51. +63 −54 ML_Dicom/Import/populate_planC_registration_field.m
  52. +97 −54 ML_Dicom/Import/populate_planC_scan_field.m
  53. +185 −85 ML_Dicom/Import/populate_planC_scan_scanInfo_field.m
  54. +104 −80 ML_Dicom/Import/populate_planC_structures_field.m
  55. +2 −1 ML_Dicom/Import/sortStructures.m
  56. +176 −93 ML_Dicom/dcmdir_add.m
  57. +33 −32 ML_Dicom/init_ML_DICOM.m
  58. +7 −2 ML_Dicom/modules/build_module_template.m
  59. +42 −33 ML_Dicom/modules/macro_tags/code_sequence_macro_tags.m
  60. +61 −49 ML_Dicom/modules/macro_tags/content_item_macro_tags.m
  61. +37 −26 ML_Dicom/modules/macro_tags/person_identification_macro_tags.m
  62. +170 −135 ML_Dicom/modules/module_tags/general_series_module_tags.m
  63. +87 −80 ML_Dicom/modules/module_tags/general_study_module_tags.m
  64. +66 −53 ML_Dicom/modules/module_tags/patient_module_tags.m
  65. +18 −11 ML_Dicom/scandir_mldcm.m
  66. +28 −16 ML_Dicom/scanfile_mldcm.m
  67. +30 −12 ML_Dicom/util/createEmptyFields.m
  68. +171 −0 ML_Dicom/util/data2dcmElement.m
  69. +17 −7 ML_Dicom/util/dcm2ml_Element.m
  70. +2 −3 ML_Dicom/util/extract_all_series.m
  71. +32 −10 ML_Dicom/util/generate_DICOM_UID_Relationships.m
  72. +86 −0 ML_Dicom/util/getTagStruct.m
  73. +176 −0 ML_Dicom/util/getTagValue.m
  74. +2 −2 ML_Dicom/util/showDCMInfo.m
  75. +16 −10 ML_Dicom/writefile_mldcm.m
@@ -27,6 +27,12 @@

"importDICOMsubDirs" : "no",

"saveDICOMheaderInPlanC" : "yes",

"structuresToImport" : "",

"structuresImportMatchCriteria" : "regex",

"createUniformizedDataset" : "yes",

"uniformizeExcludeStructs" : ["normaltissue", "CT_EXTERNAL"],
@@ -82,8 +82,9 @@ function CERRImportDCM4CHE()
dirs(2) = [];
dirs(1).name = '';

excludePixelDataFlag = true;
for i = 1:length(dirs)
patient = scandir_mldcm(fullfile(path, dirs(i).name), hWaitbar, i);
patient = scandir_mldcm(fullfile(path, dirs(i).name), hWaitbar, i, excludePixelDataFlag);
if ~isempty(patient)
for j = 1:length(patient.PATIENT)
dcmdirS.(['patient_' num2str(patientNum)]) = patient.PATIENT(j);
@@ -7,15 +7,16 @@
%Written IEN

% Get Patient weight in grams
if isfield(dicomhd,'PatientWeight')
ptweight = dicomhd.PatientWeight*1000; % in grams
elseif isfield(dicomhd,'PatientsWeight')
ptweight = dicomhd.PatientsWeight*1000; % in grams
else
disp('Patient Weight not found. SUV calculation ignored.')
SUV=slice;
return
end
ptweight = dicomhd.patientWeight*1000;
% if isfield(dicomhd,'PatientWeight')
% ptweight = dicomhd.PatientWeight*1000; % in grams
% elseif isfield(dicomhd,'PatientsWeight')
% ptweight = dicomhd.PatientsWeight*1000; % in grams
% else
% disp('Patient Weight not found. SUV calculation ignored.')
% SUV=slice;
% return
% end

if isempty(ptweight) || ptweight==0
disp('Patient Weight is missing. SUV calculation ignored.');
@@ -24,18 +25,22 @@
end

% Get Scan time
scantime=dcm_hhmmss(dicomhd.AcquisitionTime);
%scantime=dcm_hhmmss(dicomhd.AcquisitionTime);
scantime=dcm_hhmmss(dicomhd.acquisitionTime);
% Get calibration factor which is the Rescale slope Attribute Name in DICOM
calibration_factor=dicomhd.RescaleSlope;
%calibration_factor=dicomhd.RescaleSlope;

% intercept=dicomhd.RescaleIntercept; Not Used

% Start Time for the Radiopharmaceutical Injection
injection_time=dcm_hhmmss(dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadiopharmaceuticalStartTime);
% injection_time=dcm_hhmmss(dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadiopharmaceuticalStartTime);
injection_time = dcm_hhmmss(dicomhd.injectionTime);
% Half Life for Radionuclide
half_life=dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadionuclideHalfLife;
% half_life=dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadionuclideHalfLife;
half_life=dicomhd.halfLife;
% Total dose injected for Radionuclide
injected_dose=dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadionuclideTotalDose;
% injected_dose=dicomhd.RadiopharmaceuticalInformationSequence.Item_1.RadionuclideTotalDose;
injected_dose=dicomhd.injectedDose;

% Calculate the decay
% decayFactor = e^(t1-t2/halflife);
@@ -39,6 +39,7 @@
'imageType' , '', ...
'caseNumber' , '', ...
'patientName' , '', ...
'patientID' , '', ...
'scanType' , '', ...
'CTOffset' , '', ...
'rescaleSlope' , '', ...
@@ -62,11 +63,25 @@
'unitNumber' , '', ...
'scanDescription' , '', ...
'scannerType' , '', ...
'manufacturer' , '', ...
'scanFileName' , '', ...
'headInOut' , '', ...
'positionInScan' , '', ...
'patientAttitude' , '', ...
'bValue' , '', ...
'bValue' , '', ...
'acquisitionDate' , '', ...
'acquisitionTime' , '', ...
'patientWeight' , '', ...
'RadiopharmaInfoS' , '', ...
'injectionTime' , '', ...
'injectedDose' , '', ...
'halfLife' , '', ...
'petImageUnits' , '', ...
'petCountSource' , '', ...
'petSeriesType' , '', ...
'petNumSlices' , '', ...
'petDecayCorrection' , '', ...
'petCorrectedImage' , '', ...
'tapeOfOrigin' , '', ...
'studyNumberOfOrigin' , '', ...
'scanID' , '', ...
@@ -79,6 +94,13 @@
'LRflippedToMatchPACS' , '', ...
'APflippedToMatchPACS' , '', ...
'SIflippedToMatchPACS' , '', ...
'studyInstanceUID' , '', ...
'seriesInstanceUID' , '', ...
'sopInstanceUID' , '', ...
'frameOfReferenceUID' , '', ...
'patientPosition' , '', ...
'imageOrientationPatient' , '', ...
'imagePositionPatient' , '', ...
'DICOMHeaders' , '');

scanInfoS(1) = [];
@@ -12,6 +12,8 @@
% etc.
%
%JRA 07/05/06
%NAV 07/19/16 updated to dcm4che3
% Used addAll over copyTo
%
%Usage:
% nWritten = export_CT_IOD(planC, filenameRoot, filenumber);
@@ -58,28 +60,28 @@
scanS = planC{indexS.scan}(scanNum);

%Build patient module.
patientobj = export_module('patient', 'scan', scanS);
patientattr = export_module('patient', 'scan', scanS);

%Build general study module.
studyobj = export_module('general_study', scanS);
studyattr = export_module('general_study', scanS);

%Build general series module.
seriesobj = export_module('general_series', scanS);
seriesattr = export_module('general_series', scanS);

%Build a frame of reference module.
frameobj = export_module('frame_of_reference', scanS);
frameattr = export_module('frame_of_reference', scanS);

%Build a general equipment module.
equipobj = export_module('general_equipment', 'scan', scanS);
equipattr = export_module('general_equipment', 'scan', scanS);

%Get rescale slope
nBits = 16;

%Determine the scaling factor if scanArray is other than uint16
modality = scanS.scanInfo(1).imageType;
if strcmpi(modality,'PT')
dcmheader = scanS.scanInfo(1).DICOMHeaders;
if max(scanS.scanArray(:)) < 500 % assume suv
dcmheader = scanS.scanInfo(1).DICOMHeaders;
if max(scanS.scanArray(:)) < 500 % assume suv
scanS.scanArray = suvToCounts(scanS.scanArray,dcmheader);
%scanS.scanArray = scanS.scanArray / dcmheader.RescaleSlope;
else
@@ -100,54 +102,55 @@
%For slice-specific modules iterate over scaninfo.
for i=1:length(scanS.scanInfo)

%Create a dcmobj to hold a single slice.
dcmobj = org.dcm4che2.data.BasicDicomObject;
%Create a attr to hold a single slice.
%CHANGE to dcm4che 3attribute
attr = org.dcm4che3.data.Attributes;

%Get info for the slice we are handling.
scanInfoS = scanS.scanInfo(i);

%Build an image module from this particular slice (scanInfoS)
imgobj = export_module('general_image', 'scan', scanInfoS);
imgattr = export_module('general_image', 'scan', scanInfoS);

%Build an image plane module from this particular slice (scanInfoS)
imgplaneobj = export_module('image_plane', 'scan', scanInfoS, scanS);
imgplaneattr = export_module('image_plane', 'scan', scanInfoS, scanS);

%Build an image pixel module from this particular slice (scanInfoS)
imgpixelobj = export_module('image_pixel', 'scan', scanInfoS, scanS, scaleFactorV);
imgpixelattr = export_module('image_pixel', 'scan', scanInfoS, scanS, scaleFactorV);

%Build an CT image module from this particular slice (scanInfoS)
if strcmpi(modality,'PT')
ctimageobj = export_module('PT_image', scanInfoS, scanS, scaleFactorV);
else
ctimageobj = export_module('CT_image', scanInfoS, scanS, scaleFactorV);
ctimageattr = export_module('PT_image', scanInfoS, scanS, scaleFactorV);
else
ctimageattr = export_module('CT_image', scanInfoS, scanS, scaleFactorV);
end

SOPobj = export_module('SOP_common', 'scanInfo', scanInfoS);

%Combine all modules into a single dcmobj.
patientobj.copyTo(dcmobj);
studyobj.copyTo(dcmobj);
seriesobj.copyTo(dcmobj);
frameobj.copyTo(dcmobj);
equipobj.copyTo(dcmobj);
imgobj.copyTo(dcmobj);
imgplaneobj.copyTo(dcmobj);
imgpixelobj.copyTo(dcmobj);
ctimageobj.copyTo(dcmobj);
SOPobj.copyTo(dcmobj);
clear imgobj imgplaneobj imgpixelobj ctimageobj SOPobj
SOPattr = export_module('SOP_common', 'scanInfo', scanInfoS);

%Combine all modules into a single attribute.
attr.addAll(patientattr);
attr.addAll(studyattr);
attr.addAll(seriesattr);
attr.addAll(frameattr);
attr.addAll(equipattr);
attr.addAll(imgattr);
attr.addAll(imgplaneattr);
attr.addAll(imgpixelattr);
attr.addAll(ctimageattr);
attr.addAll(SOPattr);

clear imgattr imgplaneattr imgpixelattr ctimageattr SOPattr

fileNum = num2str(filenumber + nWritten);
filename = fullfile(destDirPath,['IMG_', repmat('0', [1 5-length(fileNum)]), fileNum]);

writefile_mldcm(dcmobj, filename);
writefile_mldcm(attr, filename);

nWritten = nWritten + 1;

clear dcmobj;
clear attr;
end

clear patientobj studyobj seriesobj frameobj equipobj
clear patientattr studyattr seriesattr frameattr equipattr

end

0 comments on commit 95b1cff

Please sign in to comment.
You can’t perform that action at this time.