Skip to content

Commit

Permalink
Update pet.py
Browse files Browse the repository at this point in the history
Former-commit-id: 6768c88
  • Loading branch information
skim2257 committed Dec 4, 2021
1 parent 48f2749 commit 7ab9ca1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions imgtools/modules/pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
import warnings
import datetime

def read_image(path):
reader = sitk.ImageSeriesReader()
dicom_names = reader.GetGDCMSeriesFileNames(path)
reader.SetFileNames(dicom_names)
reader.MetaDataDictionaryArrayUpdateOn()
reader.LoadPrivateTagsOn()

return reader.Execute()

class PET(sitk.Image):
def __init__(self, img_pet, df):
super().__init__(img_pet)
self.img_pet = img_pet
self.df = df

@classmethod
def from_dicom_pet(cls, pet, path, type="SUV"):
def from_dicom_pet(cls, path, type="SUV"):
'''
Reads the PET scan and returns the data frame and the image dosage in SITK format
There are two types of existing formats which has to be mentioned in the type
Expand All @@ -26,6 +35,7 @@ def from_dicom_pet(cls, pet, path, type="SUV"):
If there is no data on SUV/ACT then backup calculation is done based on the formula in the documentation, although, it may
have some error.
'''
pet = read_image(path)
path_one = os.path.join(path,os.listdir(path)[0])
df = pydicom.dcmread(path_one)
try:
Expand Down Expand Up @@ -122,4 +132,4 @@ def calc_factor(df, type: str):
if type == "SUV":
return suv
else:
return 1/a
return 1/a

0 comments on commit 7ab9ca1

Please sign in to comment.