unitedright.blogg.se

Itk metaimage to dicom
Itk metaimage to dicom









I believe that GDCM+ITK handles this correctly. It is probably best to apply the intercept and scale from DICOM, as long as they can be inverted when writing to disk (and handled well, in general - e.g., pixel type in memory might need to change from the pixel type used in the file). ITK’s MetaIO image reader are only setup to read a single image from a MetaIO file, so yes, tags after the first occurrence of ElementDataFile are ignored. If the reader is used correctly (see MetaSpatialObjectReader) then any tags after a terminating tag are applied to the next object in the file. In this way, MetaIO can actually support multiple objects being defined within the same file. Certain tags in MetaIO are “terminating” tags - they indicate the end of an object definition. mhd file / ElementToIntensityFunctionSlope / different behaviour for DICOM)?īy design, tags below ElementDataFile are ignored. With this information, is there any further advice/comments on these three aspects (order of tags in the. They are not forwarded as custom tags to ITK, so they are lost when reading an image with ITK, even though according to metaIO’s documentation, they are implemented for the exact same reason.Īnd, again, in case of DICOM, rescaleIntercept are applied while reading bulk data (voxels), see itkGDCMImageIO.cxx, line 327 ff., so this is not handled by the application but by ITK. I was more interested in the two dedicated mod-tags ElementToIntensityFunctionSlope/Offset, which are seem to provide the same functionality, but which are listed in metaIO as dedicated tags for the image type. mhd (again, they seem to be ignored otherwise) - I can dig out more information if needed. If these tags are listed above the ElementDataFile line in the.the key “rescaleIntercept”/“rescaleSlope”, or with their corresponding DICOM key rescaleIntercept/Slope are given as custom metadata attributes with e.g.

ITK METAIMAGE TO DICOM CODE

mhd image can include custom tags that are read into ITK’s MetaDataDictionary for the ImageIOBase and then later handled by the application, perfectly fine (even though the current code for metaIO reading seems to ignore all user tags that are written below the ElementDataFile line in the mhd. mainForm.statusbar->showMessage("Window intensity scaling") QApplication::processEvents().if (windowCenter!=0 & windowWidth!=0 & mainForm.actionUse_DICOMs_windowing->isChecked()).windowWidth=QString::fromStdString(entryValue->GetMetaDataObjectValue()).toDouble().windowCenter=QString::fromStdString(entryValue->GetMetaDataObjectValue()).toDouble().series_description = entryValue->GetMetaDataObjectValue().

itk metaimage to dicom

  • dynamic_cast(itr->second.GetPointer()).
  • MetaDataStringType::Pointer entryValue =.
  • //check presence of the metadata and use it if found.
  • If you want to explicitly handle it, take a look at this code fragment: save (save_path + '/' + str (i ) + '.DICOM reader applies the slope and intercept values by default. fromarray (scan ) #Here is the extracted image data Make_dir (save_path ) for i in range (scan. shape ) #Image size print ( 'spacing: ', spacing ) #interval print ( '# slice: ', len (scan ) ) #Number of slices #plot_ct_scan(scan) GetArrayFromImage (data ) print ( 'scan.shape' ,scan. join (root ,path ) ) #Read mhd file #print(data) Plot = plots if num_row = 1 else plots ĭata =sitk. subplots (num_row, num_column, figsize = (num_column * 5, num_row * 5 ) ) for i in range ( 0, num_row *num_column ) : Num_row = (num_slices //jump + num_column - 1 ) // num_columnį, plots = plt. makedirs (save_path ) #Integrate all pictures of a patient into one picture and print it out def plot_ct_scan (scan, num_column = 4, jump = 1 ) :

    itk metaimage to dicom

    #Create empty directory def make_dir (save_path ) : if not os. #Get the name of the subfolder in the file def get_file_name (filename ) : for root, dirs, files in os. My data storage is roughly as follows E:/105casesMask_Seg is the total data folder, the Cxxx folder stores the mhd files of each patient, the file name is equivalent to the patient_name later #Import the required package import os









    Itk metaimage to dicom