Commit 5ba96ad230f514c91aa81f592dfd91eac92c5fcf
1 parent
3c29741e
Exists in
master
and in
6 other branches
ADD: Add a dicom file inside of inv3 project file
Showing
2 changed files
with
18 additions
and
3 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -362,7 +362,7 @@ class Controller(): |
362 | 362 | proj.modality = dicom.acquisition.modality |
363 | 363 | proj.SetAcquisitionModality(dicom.acquisition.modality) |
364 | 364 | proj.imagedata = imagedata |
365 | - #proj.dicom = dicom | |
365 | + proj.dicom_sample = dicom | |
366 | 366 | proj.original_orientation =\ |
367 | 367 | name_to_const[dicom.image.orientation_label] |
368 | 368 | proj.window = float(dicom.image.window) | ... | ... |
invesalius/project.py
... | ... | @@ -34,6 +34,7 @@ import data.mask as msk |
34 | 34 | import data.polydata_utils as pu |
35 | 35 | import data.surface as srf |
36 | 36 | from presets import Presets |
37 | +from reader import dicom | |
37 | 38 | from utils import Singleton |
38 | 39 | import version |
39 | 40 | |
... | ... | @@ -45,7 +46,7 @@ class Project(object): |
45 | 46 | def __init__(self): |
46 | 47 | # Patient/ acquistion information |
47 | 48 | self.name = '' |
48 | - #self.dicom = '' | |
49 | + self.dicom_sample = '' | |
49 | 50 | self.modality = '' |
50 | 51 | self.original_orientation = '' |
51 | 52 | self.min_threshold = '' |
... | ... | @@ -175,6 +176,10 @@ class Project(object): |
175 | 176 | if getattr(self.__dict__[key], 'SavePlist', None): |
176 | 177 | project[key] = {'#plist': |
177 | 178 | self.__dict__[key].SavePlist(filename_tmp).decode('utf-8')} |
179 | + elif key == 'dicom_sample': | |
180 | + shutil.copy(self.dicom_sample.parser.filename, | |
181 | + os.path.join(dir_temp, 'sample.dcm')) | |
182 | + project[key] = 'sample.dcm' | |
178 | 183 | else: |
179 | 184 | project[key] = self.__dict__[key] |
180 | 185 | |
... | ... | @@ -212,8 +217,10 @@ class Project(object): |
212 | 217 | ow.SetInstance(fow) |
213 | 218 | |
214 | 219 | filelist = Extract(filename, tempfile.gettempdir()) |
215 | - main_plist = min(filelist, key=lambda x: len(x)) | |
220 | + main_plist = min(filter(lambda x: x.endswith('.plist'), filelist), | |
221 | + key=lambda x: len(x)) | |
216 | 222 | #print main_plist |
223 | + print main_plist | |
217 | 224 | project = plistlib.readPlist(main_plist) |
218 | 225 | |
219 | 226 | #print "antes", self.__dict__ |
... | ... | @@ -233,6 +240,14 @@ class Project(object): |
233 | 240 | p = Presets() |
234 | 241 | p.OpenPlist(path) |
235 | 242 | self.presets = p |
243 | + elif key == 'dicom_sample': | |
244 | + path = os.path.join(dirpath, project[key]) | |
245 | + p = dicom.Parser() | |
246 | + p.SetFileName(path) | |
247 | + d = dicom.Dicom() | |
248 | + d.SetParser(p) | |
249 | + self.dicom_sample = d | |
250 | + | |
236 | 251 | elif key == 'mask_dict': |
237 | 252 | self.mask_dict = {} |
238 | 253 | for mask in project[key]: | ... | ... |