ds.ImageType = '1' # Derived = 1, Primary = 2 #Set image parameters ds.SpacingBetweenSlices = '2.0' ds.ImageOrientationPatient = ['-1', '0', '0', '0', '-1', '0'] ds.SamplesPerPixel = 1 ds.PhotometricInterpretation = 'MONOCHROME2' ds.Rows = 109 ds.Columns = 91 ds.PixelSpacing = ['-2.0', '2.0'] ds.BitsAllocated = 8 # Binary = 1 ds.BitsStored = 8 # Binary = 1 ds.HighBit = 7 # Binary = 0 ds.SegmentationType = 'FRACTIONAL' #FRACTIONAL or BINARY ds.SegmentationFractionalType = 'OCCUPANCY' #Can be OCCUPANCY or PROBABILITY ds.MaximumFractionalValue = 116 # 116 is the number of labels in AAL ds.PixelRepresentation = 1 # Set the transfer syntax ds.is_little_endian = True ds.is_implicit_VR = True print "Writing test file", filename ds.save_as(filename) print "File saved." # Write as a different transfer syntax ds.file_meta.TransferSyntaxUID = dicom.UID.ExplicitVRBigEndian #XXX shouldn't need this but pydicom 0.9.5 bug not recognizing transfer syntax ds.is_little_endian = False ds.is_implicit_VR = False