Commit 35f8c80992eb5fcf85ed71065a7e83a064c8bbc4

Authored by tatiana
1 parent dd4ee4d0

ENC: Changed parser None values for empty strings

Showing 1 changed file with 140 additions and 137 deletions   Show diff stats
invesalius/reader/dicom.py
@@ -88,7 +88,7 @@ class Parser(): @@ -88,7 +88,7 @@ class Parser():
88 """ 88 """
89 89
90 def __init__(self): 90 def __init__(self):
91 - self.filename = None 91 + self.filename = ""
92 self.vtkgdcm_reader = vtkgdcm.vtkGDCMImageReader() 92 self.vtkgdcm_reader = vtkgdcm.vtkGDCMImageReader()
93 93
94 def GetAcquisitionDate(self): 94 def GetAcquisitionDate(self):
@@ -112,7 +112,7 @@ class Parser(): @@ -112,7 +112,7 @@ class Parser():
112 def GetAcquisitionNumber(self): 112 def GetAcquisitionNumber(self):
113 """ 113 """
114 Return integer related to acquisition of this slice. 114 Return integer related to acquisition of this slice.
115 - Return None if field is not defined. 115 + Return "" if field is not defined.
116 116
117 DICOM standard tag (0x0020, 0x0012) was used. 117 DICOM standard tag (0x0020, 0x0012) was used.
118 """ 118 """
@@ -122,7 +122,7 @@ class Parser(): @@ -122,7 +122,7 @@ class Parser():
122 data = ds.GetDataElement(tag).GetValue() 122 data = ds.GetDataElement(tag).GetValue()
123 if (data): 123 if (data):
124 return int(str(data)) 124 return int(str(data))
125 - return None 125 + return ""
126 126
127 def GetAccessionNumber(self): 127 def GetAccessionNumber(self):
128 """ 128 """
@@ -136,7 +136,7 @@ class Parser(): @@ -136,7 +136,7 @@ class Parser():
136 data = ds.GetDataElement(tag).GetValue() 136 data = ds.GetDataElement(tag).GetValue()
137 if (data): 137 if (data):
138 return int(str(data)) 138 return int(str(data))
139 - return None 139 + return ""
140 140
141 def GetAcquisitionTime(self): 141 def GetAcquisitionTime(self):
142 """ 142 """
@@ -216,14 +216,14 @@ class Parser(): @@ -216,14 +216,14 @@ class Parser():
216 """ 216 """
217 Return image window center / level (related to brightness). 217 Return image window center / level (related to brightness).
218 This is an integer or a floating point. If the value can't 218 This is an integer or a floating point. If the value can't
219 - be read, return None. 219 + be read, return "".
220 220
221 By default, only one level value is returned, according to 221 By default, only one level value is returned, according to
222 "preset" parameter. If no value is passed, WL_PRESET constant 222 "preset" parameter. If no value is passed, WL_PRESET constant
223 is used. In case one wishes to acquire a list with all 223 is used. In case one wishes to acquire a list with all
224 level values, one should set "multiple" parameter to True. 224 level values, one should set "multiple" parameter to True.
225 225
226 - Return None if field is not defined. 226 + Return "" if field is not defined.
227 227
228 DICOM standard tag (0x0028,0x1050) was used. 228 DICOM standard tag (0x0028,0x1050) was used.
229 """ 229 """
@@ -244,20 +244,20 @@ class Parser(): @@ -244,20 +244,20 @@ class Parser():
244 return value_list 244 return value_list
245 else: 245 else:
246 return value_list[preset] 246 return value_list[preset]
247 - return None 247 + return ""
248 248
249 def GetImageWindowWidth(self, preset=WL_PRESET, multiple=WL_MULT): 249 def GetImageWindowWidth(self, preset=WL_PRESET, multiple=WL_MULT):
250 """ 250 """
251 Return image window width (related to contrast). This is an 251 Return image window width (related to contrast). This is an
252 integer or a floating point. If the value can't be read, 252 integer or a floating point. If the value can't be read,
253 - return None. 253 + return "".
254 254
255 By default, only one width value is returned, according to 255 By default, only one width value is returned, according to
256 "preset" parameter. If no value is passed, WL_PRESET constant 256 "preset" parameter. If no value is passed, WL_PRESET constant
257 is used. In case one wishes to acquire a list with all 257 is used. In case one wishes to acquire a list with all
258 preset values, one should set "multiple" parameter to True. 258 preset values, one should set "multiple" parameter to True.
259 259
260 - Return None if field is not defined. 260 + Return "" if field is not defined.
261 261
262 DICOM standard tag (0x0028,0x1051) was used. 262 DICOM standard tag (0x0028,0x1051) was used.
263 """ 263 """
@@ -279,7 +279,7 @@ class Parser(): @@ -279,7 +279,7 @@ class Parser():
279 return str(value_list) 279 return str(value_list)
280 else: 280 else:
281 return str(value_list[preset]) 281 return str(value_list[preset])
282 - return None 282 + return ""
283 283
284 def GetImagePosition(self): 284 def GetImagePosition(self):
285 """ 285 """
@@ -287,7 +287,7 @@ class Parser(): @@ -287,7 +287,7 @@ class Parser():
287 of the upper left corner voxel (first voxel transmitted). 287 of the upper left corner voxel (first voxel transmitted).
288 This value is given in mm. Number might be floating point 288 This value is given in mm. Number might be floating point
289 or integer. 289 or integer.
290 - Return None if field is not defined. 290 + Return "" if field is not defined.
291 291
292 DICOM standard tag (0x0020, 0x0032) was used. 292 DICOM standard tag (0x0020, 0x0032) was used.
293 """ 293 """
@@ -297,13 +297,13 @@ class Parser(): @@ -297,13 +297,13 @@ class Parser():
297 data = str(ds.GetDataElement(tag).GetValue()) 297 data = str(ds.GetDataElement(tag).GetValue())
298 if (data): 298 if (data):
299 return [eval(value) for value in data.split('\\')] 299 return [eval(value) for value in data.split('\\')]
300 - return None 300 + return ""
301 301
302 def GetImageLocation(self): 302 def GetImageLocation(self):
303 """ 303 """
304 Return image location (floating value), related to the 304 Return image location (floating value), related to the
305 series acquisition. 305 series acquisition.
306 - Return None if field is not defined. 306 + Return "" if field is not defined.
307 307
308 DICOM standard tag (0x0020, 0x0032) was used. 308 DICOM standard tag (0x0020, 0x0032) was used.
309 """ 309 """
@@ -313,12 +313,12 @@ class Parser(): @@ -313,12 +313,12 @@ class Parser():
313 data = str(ds.GetDataElement(tag).GetValue()) 313 data = str(ds.GetDataElement(tag).GetValue())
314 if (data): 314 if (data):
315 return eval(data) 315 return eval(data)
316 - return None 316 + return ""
317 317
318 def GetImageOffset(self): 318 def GetImageOffset(self):
319 """ 319 """
320 Return image pixel offset (memory position). 320 Return image pixel offset (memory position).
321 - Return None if field is not defined. 321 + Return "" if field is not defined.
322 322
323 DICOM standard tag (0x7fe0, 0x0010) was used. 323 DICOM standard tag (0x7fe0, 0x0010) was used.
324 """ 324 """
@@ -328,14 +328,14 @@ class Parser(): @@ -328,14 +328,14 @@ class Parser():
328 data = str(ds.GetDataElement(tag).GetValue()) 328 data = str(ds.GetDataElement(tag).GetValue())
329 if (data): 329 if (data):
330 return int(data.split(':')[1]) 330 return int(data.split(':')[1])
331 - return None 331 + return ""
332 332
333 333
334 def GetImageSeriesNumber(self): 334 def GetImageSeriesNumber(self):
335 """ 335 """
336 Return integer related to acquisition series where this 336 Return integer related to acquisition series where this
337 slice is included. 337 slice is included.
338 - Return None if field is not defined. 338 + Return "" if field is not defined.
339 339
340 DICOM standard tag (0x0020, 0x0011) was used. 340 DICOM standard tag (0x0020, 0x0011) was used.
341 """ 341 """
@@ -343,9 +343,9 @@ class Parser(): @@ -343,9 +343,9 @@ class Parser():
343 ds = self.gdcm_reader.GetFile().GetDataSet() 343 ds = self.gdcm_reader.GetFile().GetDataSet()
344 if ds.FindDataElement(tag): 344 if ds.FindDataElement(tag):
345 data = str(ds.GetDataElement(tag).GetValue()) 345 data = str(ds.GetDataElement(tag).GetValue())
346 - if (data) and (data != 'None'): 346 + if (data) and (data != '""'):
347 return int(data) 347 return int(data)
348 - return None 348 + return ""
349 349
350 350
351 def GetPixelSpacing(self): 351 def GetPixelSpacing(self):
@@ -354,7 +354,7 @@ class Parser(): @@ -354,7 +354,7 @@ class Parser():
354 each pair of pixel. That is, adjacent row spacing (delimiter) 354 each pair of pixel. That is, adjacent row spacing (delimiter)
355 and adjacent column spacing. Values are usually floating point 355 and adjacent column spacing. Values are usually floating point
356 and represent mm. 356 and represent mm.
357 - Return None if field is not defined. 357 + Return "" if field is not defined.
358 358
359 DICOM standard tag (0x0028, 0x0030) was used. 359 DICOM standard tag (0x0028, 0x0030) was used.
360 """ 360 """
@@ -364,26 +364,26 @@ class Parser(): @@ -364,26 +364,26 @@ class Parser():
364 data = str(ds.GetDataElement(tag).GetValue()) 364 data = str(ds.GetDataElement(tag).GetValue())
365 if (data): 365 if (data):
366 return [eval(value) for value in data.split('\\')] 366 return [eval(value) for value in data.split('\\')]
367 - return None 367 + return ""
368 368
369 def GetImagePixelSpacingY(self): 369 def GetImagePixelSpacingY(self):
370 """ 370 """
371 Return spacing between adjacent pixels considerating y axis 371 Return spacing between adjacent pixels considerating y axis
372 (height). Values are usually floating point and represent mm. 372 (height). Values are usually floating point and represent mm.
373 - Return None if field is not defined. 373 + Return "" if field is not defined.
374 374
375 DICOM standard tag (0x0028, 0x0030) was used. 375 DICOM standard tag (0x0028, 0x0030) was used.
376 """ 376 """
377 spacing = self.GetPixelSpacing() 377 spacing = self.GetPixelSpacing()
378 if spacing: 378 if spacing:
379 return spacing[1] 379 return spacing[1]
380 - return None 380 + return ""
381 381
382 def GetImagePixelSpacingX(self): 382 def GetImagePixelSpacingX(self):
383 """ 383 """
384 Return spacing between adjacent pixels considerating x axis 384 Return spacing between adjacent pixels considerating x axis
385 (width). Values are usually floating point and represent mm. 385 (width). Values are usually floating point and represent mm.
386 - Return None if field is not defined. 386 + Return "" if field is not defined.
387 387
388 DICOM standard tag (0x0028, 0x0030) was used. 388 DICOM standard tag (0x0028, 0x0030) was used.
389 """ 389 """
@@ -391,12 +391,12 @@ class Parser(): @@ -391,12 +391,12 @@ class Parser():
391 spacing = self.GetPixelSpacing() 391 spacing = self.GetPixelSpacing()
392 if spacing: 392 if spacing:
393 return spacing[0] 393 return spacing[0]
394 - return None 394 + return ""
395 395
396 def GetPatientWeight(self): 396 def GetPatientWeight(self):
397 """ 397 """
398 Return patient's weight as a float value (kilograms). 398 Return patient's weight as a float value (kilograms).
399 - Return None if field is not defined. 399 + Return "" if field is not defined.
400 400
401 DICOM standard tag (0x0010, 0x1030) was used. 401 DICOM standard tag (0x0010, 0x1030) was used.
402 """ 402 """
@@ -406,12 +406,12 @@ class Parser(): @@ -406,12 +406,12 @@ class Parser():
406 data = str(ds.GetDataElement(tag).GetValue()) 406 data = str(ds.GetDataElement(tag).GetValue())
407 if (data): 407 if (data):
408 return float(data) 408 return float(data)
409 - return None 409 + return ""
410 410
411 def GetPatientHeight(self): 411 def GetPatientHeight(self):
412 """ 412 """
413 Return patient's height as a float value (meters). 413 Return patient's height as a float value (meters).
414 - Return None if field is not defined. 414 + Return "" if field is not defined.
415 415
416 DICOM standard tag (0x0010, 0x1030) was used. 416 DICOM standard tag (0x0010, 0x1030) was used.
417 """ 417 """
@@ -421,7 +421,7 @@ class Parser(): @@ -421,7 +421,7 @@ class Parser():
421 data = str(ds.GetDataElement(tag).GetValue()) 421 data = str(ds.GetDataElement(tag).GetValue())
422 if (data): 422 if (data):
423 return float(data) 423 return float(data)
424 - return None 424 + return ""
425 425
426 def GetPatientAddress(self): 426 def GetPatientAddress(self):
427 """ 427 """
@@ -435,12 +435,12 @@ class Parser(): @@ -435,12 +435,12 @@ class Parser():
435 data = str(ds.GetDataElement(tag).GetValue()) 435 data = str(ds.GetDataElement(tag).GetValue())
436 if (data): 436 if (data):
437 return data 437 return data
438 - return None 438 + return ""
439 439
440 def GetPatientMilitarRank(self): 440 def GetPatientMilitarRank(self):
441 """ 441 """
442 Return string containing patient's militar rank. 442 Return string containing patient's militar rank.
443 - Return None if field is not defined. 443 + Return "" if field is not defined.
444 444
445 DICOM standard tag (0x0010, 0x1080) was used. 445 DICOM standard tag (0x0010, 0x1080) was used.
446 """ 446 """
@@ -450,14 +450,14 @@ class Parser(): @@ -450,14 +450,14 @@ class Parser():
450 data = str(ds.GetDataElement(tag).GetValue()) 450 data = str(ds.GetDataElement(tag).GetValue())
451 if (data): 451 if (data):
452 return data 452 return data
453 - return None 453 + return ""
454 454
455 def GetPatientMilitarBranch(self): 455 def GetPatientMilitarBranch(self):
456 """ 456 """
457 Return string containing the militar branch. 457 Return string containing the militar branch.
458 The country allegiance may also be included 458 The country allegiance may also be included
459 (e.g. B.R. Army). 459 (e.g. B.R. Army).
460 - Return None if field is not defined. 460 + Return "" if field is not defined.
461 461
462 DICOM standard tag (0x0010, 0x1081) was used. 462 DICOM standard tag (0x0010, 0x1081) was used.
463 """ 463 """
@@ -467,13 +467,13 @@ class Parser(): @@ -467,13 +467,13 @@ class Parser():
467 data = str(ds.GetDataElement(tag).GetValue()) 467 data = str(ds.GetDataElement(tag).GetValue())
468 if (data): 468 if (data):
469 return data 469 return data
470 - return None 470 + return ""
471 471
472 def GetPatientCountry(self): 472 def GetPatientCountry(self):
473 """ 473 """
474 Return string containing the country where the patient 474 Return string containing the country where the patient
475 currently resides. 475 currently resides.
476 - Return None if field is not defined. 476 + Return "" if field is not defined.
477 477
478 DICOM standard tag (0x0010, 0x2150) was used. 478 DICOM standard tag (0x0010, 0x2150) was used.
479 """ 479 """
@@ -483,13 +483,13 @@ class Parser(): @@ -483,13 +483,13 @@ class Parser():
483 data = str(ds.GetDataElement(tag).GetValue()) 483 data = str(ds.GetDataElement(tag).GetValue())
484 if (data): 484 if (data):
485 return data 485 return data
486 - return None 486 + return ""
487 487
488 def GetPatientRegion(self): 488 def GetPatientRegion(self):
489 """ 489 """
490 Return string containing the region where the patient 490 Return string containing the region where the patient
491 currently resides. 491 currently resides.
492 - Return None if field is not defined. 492 + Return "" if field is not defined.
493 493
494 DICOM standard tag (0x0010, 0x2152) was used. 494 DICOM standard tag (0x0010, 0x2152) was used.
495 """ 495 """
@@ -499,12 +499,12 @@ class Parser(): @@ -499,12 +499,12 @@ class Parser():
499 data = str(ds.GetDataElement(tag).GetValue()) 499 data = str(ds.GetDataElement(tag).GetValue())
500 if (data): 500 if (data):
501 return data 501 return data
502 - return None 502 + return ""
503 503
504 def GetPatientTelephone(self): 504 def GetPatientTelephone(self):
505 """ 505 """
506 Return string containing the patient's telephone number. 506 Return string containing the patient's telephone number.
507 - Return None if field is not defined. 507 + Return "" if field is not defined.
508 508
509 DICOM standard tag (0x0010, 0x2154) was used. 509 DICOM standard tag (0x0010, 0x2154) was used.
510 """ 510 """
@@ -514,13 +514,13 @@ class Parser(): @@ -514,13 +514,13 @@ class Parser():
514 data = str(ds.GetDataElement(tag).GetValue()) 514 data = str(ds.GetDataElement(tag).GetValue())
515 if (data): 515 if (data):
516 return data 516 return data
517 - return None 517 + return ""
518 518
519 def GetPatientResponsible(self): 519 def GetPatientResponsible(self):
520 """ 520 """
521 Return string containing the name of the person with 521 Return string containing the name of the person with
522 medical decision authority in regards to this patient. 522 medical decision authority in regards to this patient.
523 - Return None if field is not defined. 523 + Return "" if field is not defined.
524 524
525 DICOM standard tag (0x0010, 0x2297) was used. 525 DICOM standard tag (0x0010, 0x2297) was used.
526 """ 526 """
@@ -530,13 +530,13 @@ class Parser(): @@ -530,13 +530,13 @@ class Parser():
530 data = str(ds.GetDataElement(tag).GetValue()) 530 data = str(ds.GetDataElement(tag).GetValue())
531 if (data): 531 if (data):
532 return data 532 return data
533 - return None 533 + return ""
534 534
535 def GetPatientResponsibleRole(self): 535 def GetPatientResponsibleRole(self):
536 """ 536 """
537 Return string containing the relationship of the responsible 537 Return string containing the relationship of the responsible
538 person in regards to this patient. 538 person in regards to this patient.
539 - Return None if field is not defined. 539 + Return "" if field is not defined.
540 540
541 DICOM standard tag (0x0010, 0x2298) was used. 541 DICOM standard tag (0x0010, 0x2298) was used.
542 """ 542 """
@@ -546,13 +546,13 @@ class Parser(): @@ -546,13 +546,13 @@ class Parser():
546 data = str(ds.GetDataElement(tag).GetValue()) 546 data = str(ds.GetDataElement(tag).GetValue())
547 if (data): 547 if (data):
548 return data 548 return data
549 - return None 549 + return ""
550 550
551 def GetPatientResponsibleOrganization(self): 551 def GetPatientResponsibleOrganization(self):
552 """ 552 """
553 Return string containing the organization name with 553 Return string containing the organization name with
554 medical decision authority in regards to this patient. 554 medical decision authority in regards to this patient.
555 - Return None if field is not defined. 555 + Return "" if field is not defined.
556 556
557 DICOM standard tag (0x0010, 0x2299) was used. 557 DICOM standard tag (0x0010, 0x2299) was used.
558 """ 558 """
@@ -562,13 +562,13 @@ class Parser(): @@ -562,13 +562,13 @@ class Parser():
562 data = str(ds.GetDataElement(tag).GetValue()) 562 data = str(ds.GetDataElement(tag).GetValue())
563 if (data): 563 if (data):
564 return data 564 return data
565 - return None 565 + return ""
566 566
567 def GetPatientMedicalCondition(self): 567 def GetPatientMedicalCondition(self):
568 """ 568 """
569 Return string containing patient medical conditions 569 Return string containing patient medical conditions
570 (e.g. contagious illness, drug allergies, etc.). 570 (e.g. contagious illness, drug allergies, etc.).
571 - Return None if field is not defined. 571 + Return "" if field is not defined.
572 572
573 DICOM standard tag (0x0010, 0x2000) was used. 573 DICOM standard tag (0x0010, 0x2000) was used.
574 """ 574 """
@@ -578,13 +578,13 @@ class Parser(): @@ -578,13 +578,13 @@ class Parser():
578 data = str(ds.GetDataElement(tag).GetValue()) 578 data = str(ds.GetDataElement(tag).GetValue())
579 if (data): 579 if (data):
580 return data 580 return data
581 - return None 581 + return ""
582 582
583 def GetPatientContrastAllergies(self): 583 def GetPatientContrastAllergies(self):
584 """ 584 """
585 Return string containing description of prior alergical 585 Return string containing description of prior alergical
586 reactions to contrast agents. 586 reactions to contrast agents.
587 - Return None if field is not defined. 587 + Return "" if field is not defined.
588 588
589 DICOM standard tag (0x0008, 0x2110) was used. 589 DICOM standard tag (0x0008, 0x2110) was used.
590 """ 590 """
@@ -594,14 +594,14 @@ class Parser(): @@ -594,14 +594,14 @@ class Parser():
594 data = str(ds.GetDataElement(tag).GetValue()) 594 data = str(ds.GetDataElement(tag).GetValue())
595 if (data): 595 if (data):
596 return data 596 return data
597 - return None 597 + return ""
598 598
599 599
600 def GetPhysicianReferringName(self): 600 def GetPhysicianReferringName(self):
601 """ 601 """
602 Return string containing physician 602 Return string containing physician
603 of the patient. 603 of the patient.
604 - Return None if field is not defined. 604 + Return "" if field is not defined.
605 605
606 DICOM standard tag (0x0008, 0x0090) was used. 606 DICOM standard tag (0x0008, 0x0090) was used.
607 """ 607 """
@@ -609,6 +609,8 @@ class Parser(): @@ -609,6 +609,8 @@ class Parser():
609 ds = self.gdcm_reader.GetFile().GetDataSet() 609 ds = self.gdcm_reader.GetFile().GetDataSet()
610 if ds.FindDataElement(tag): 610 if ds.FindDataElement(tag):
611 data = str(ds.GetDataElement(tag).GetValue()) 611 data = str(ds.GetDataElement(tag).GetValue())
  612 + if data == "None":
  613 + return ""
612 if (data): 614 if (data):
613 return data 615 return data
614 return "" 616 return ""
@@ -617,7 +619,7 @@ class Parser(): @@ -617,7 +619,7 @@ class Parser():
617 def GetPhysicianReferringAddress(self): 619 def GetPhysicianReferringAddress(self):
618 """ 620 """
619 Return string containing physician's address. 621 Return string containing physician's address.
620 - Return None if field is not defined. 622 + Return "" if field is not defined.
621 623
622 DICOM standard tag (0x0008, 0x0092) was used. 624 DICOM standard tag (0x0008, 0x0092) was used.
623 """ 625 """
@@ -627,12 +629,12 @@ class Parser(): @@ -627,12 +629,12 @@ class Parser():
627 data = str(ds.GetDataElement(tag).GetValue()) 629 data = str(ds.GetDataElement(tag).GetValue())
628 if (data): 630 if (data):
629 return data 631 return data
630 - return None 632 + return ""
631 633
632 def GetPhysicianeReferringTelephone(self): 634 def GetPhysicianeReferringTelephone(self):
633 """ 635 """
634 Return string containing physician's telephone. 636 Return string containing physician's telephone.
635 - Return None if field is not defined. 637 + Return "" if field is not defined.
636 638
637 DICOM standard tag (0x0008, 0x0094) was used. 639 DICOM standard tag (0x0008, 0x0094) was used.
638 """ 640 """
@@ -642,14 +644,14 @@ class Parser(): @@ -642,14 +644,14 @@ class Parser():
642 data = str(ds.GetDataElement(tag).GetValue()) 644 data = str(ds.GetDataElement(tag).GetValue())
643 if (data): 645 if (data):
644 return data 646 return data
645 - return None 647 + return ""
646 648
647 def GetImageType(self): 649 def GetImageType(self):
648 """ 650 """
649 Return list containing strings related to image origin. 651 Return list containing strings related to image origin.
650 Eg: ["ORIGINAL", "PRIMARY", "AXIAL"] or ["DERIVED", 652 Eg: ["ORIGINAL", "PRIMARY", "AXIAL"] or ["DERIVED",
651 "SECONDARY", "OTHER"] 653 "SECONDARY", "OTHER"]
652 - Return None if field is not defined. 654 + Return "" if field is not defined.
653 655
654 Critical DICOM tag (0x0008, 0x0008). Cannot be editted. 656 Critical DICOM tag (0x0008, 0x0008). Cannot be editted.
655 """ 657 """
@@ -660,13 +662,13 @@ class Parser(): @@ -660,13 +662,13 @@ class Parser():
660 if (data): 662 if (data):
661 663
662 return data.split('\\') 664 return data.split('\\')
663 - return None 665 + return ""
664 666
665 def GetSOPClassUID(self): 667 def GetSOPClassUID(self):
666 """ 668 """
667 Return string containing the Unique Identifier for the SOP 669 Return string containing the Unique Identifier for the SOP
668 class. 670 class.
669 - Return None if field is not defined. 671 + Return "" if field is not defined.
670 672
671 Critical DICOM tag (0x0008, 0x0016). Cannot be edited. 673 Critical DICOM tag (0x0008, 0x0016). Cannot be edited.
672 """ 674 """
@@ -676,13 +678,13 @@ class Parser(): @@ -676,13 +678,13 @@ class Parser():
676 data = str(ds.GetDataElement(tag).GetValue()) 678 data = str(ds.GetDataElement(tag).GetValue())
677 if (data): 679 if (data):
678 return data 680 return data
679 - return None 681 + return ""
680 682
681 def GetSOPInstanceUID(self): 683 def GetSOPInstanceUID(self):
682 """ 684 """
683 Return string containing Unique Identifier for the SOP 685 Return string containing Unique Identifier for the SOP
684 instance. 686 instance.
685 - Return None if field is not defined. 687 + Return "" if field is not defined.
686 688
687 Critical DICOM tag (0x0008, 0x0018). Cannot be edited. 689 Critical DICOM tag (0x0008, 0x0018). Cannot be edited.
688 """ 690 """
@@ -692,7 +694,7 @@ class Parser(): @@ -692,7 +694,7 @@ class Parser():
692 data = str(ds.GetDataElement(tag).GetValue()) 694 data = str(ds.GetDataElement(tag).GetValue())
693 if (data): 695 if (data):
694 return data 696 return data
695 - return None 697 + return ""
696 698
697 def GetSeriesDescription(self): 699 def GetSeriesDescription(self):
698 """ 700 """
@@ -706,13 +708,13 @@ class Parser(): @@ -706,13 +708,13 @@ class Parser():
706 data = str(ds.GetDataElement(tag).GetValue()) 708 data = str(ds.GetDataElement(tag).GetValue())
707 if (data): 709 if (data):
708 return data 710 return data
709 - return None 711 + return ""
710 712
711 def GetStudyInstanceUID(self): 713 def GetStudyInstanceUID(self):
712 """ 714 """
713 Return string containing Unique Identifier of the 715 Return string containing Unique Identifier of the
714 Study Instance. 716 Study Instance.
715 - Return None if field is not defined. 717 + Return "" if field is not defined.
716 718
717 Critical DICOM Tag (0x0020,0x000D). Cannot be edited. 719 Critical DICOM Tag (0x0020,0x000D). Cannot be edited.
718 """ 720 """
@@ -722,7 +724,7 @@ class Parser(): @@ -722,7 +724,7 @@ class Parser():
722 data = str(ds.GetDataElement(tag).GetValue()) 724 data = str(ds.GetDataElement(tag).GetValue())
723 if (data): 725 if (data):
724 return data 726 return data
725 - return None 727 + return ""
726 728
727 def GetImagePatientOrientation(self): 729 def GetImagePatientOrientation(self):
728 """ 730 """
@@ -731,7 +733,7 @@ class Parser(): @@ -731,7 +733,7 @@ class Parser():
731 point representation. The first three values are associated 733 point representation. The first three values are associated
732 to row orientation and the three last values are related 734 to row orientation and the three last values are related
733 to column orientation. 735 to column orientation.
734 - Return None if field is not defined. 736 + Return "" if field is not defined.
735 737
736 Critical DICOM tag (0x0020,0x0037). Cannot be edited. 738 Critical DICOM tag (0x0020,0x0037). Cannot be edited.
737 """ 739 """
@@ -748,7 +750,7 @@ class Parser(): @@ -748,7 +750,7 @@ class Parser():
748 Return matrix [x0, x1, x2] related to patient images' 750 Return matrix [x0, x1, x2] related to patient images'
749 column acquisition orientation. All values are in floating 751 column acquisition orientation. All values are in floating
750 point representation. 752 point representation.
751 - Return None if field is not defined. 753 + Return "" if field is not defined.
752 754
753 Critical DICOM tag (0x0020,0x0037). Cannot be edited. 755 Critical DICOM tag (0x0020,0x0037). Cannot be edited.
754 """ 756 """
@@ -765,7 +767,7 @@ class Parser(): @@ -765,7 +767,7 @@ class Parser():
765 Return matrix [y0, y1, y2] related to patient images' 767 Return matrix [y0, y1, y2] related to patient images'
766 row acquisition orientation. All values are in floating 768 row acquisition orientation. All values are in floating
767 point representation. 769 point representation.
768 - Return None if field is not defined. 770 + Return "" if field is not defined.
769 771
770 Critical DICOM tag (0x0020,0x0037). Cannot be edited. 772 Critical DICOM tag (0x0020,0x0037). Cannot be edited.
771 """ 773 """
@@ -780,7 +782,7 @@ class Parser(): @@ -780,7 +782,7 @@ class Parser():
780 def GetFrameReferenceUID(self): 782 def GetFrameReferenceUID(self):
781 """ 783 """
782 Return string containing Frame of Reference UID. 784 Return string containing Frame of Reference UID.
783 - Return None if field is not defined. 785 + Return "" if field is not defined.
784 786
785 Critical DICOM tag (0x0020,0x0052). Cannot be edited. 787 Critical DICOM tag (0x0020,0x0052). Cannot be edited.
786 """ 788 """
@@ -790,12 +792,12 @@ class Parser(): @@ -790,12 +792,12 @@ class Parser():
790 data = str(ds.GetDataElement(tag).GetValue()) 792 data = str(ds.GetDataElement(tag).GetValue())
791 if (data): 793 if (data):
792 return data 794 return data
793 - return None 795 + return ""
794 796
795 def GetImageSamplesPerPixel(self): 797 def GetImageSamplesPerPixel(self):
796 """ 798 """
797 Return integer related to Samples per Pixel. Eg. 1. 799 Return integer related to Samples per Pixel. Eg. 1.
798 - Return None if field is not defined. 800 + Return "" if field is not defined.
799 801
800 Critical DICOM tag (0x0028,0x0002). Cannot be edited. 802 Critical DICOM tag (0x0028,0x0002). Cannot be edited.
801 """ 803 """
@@ -805,13 +807,13 @@ class Parser(): @@ -805,13 +807,13 @@ class Parser():
805 res = sf.ToStringPair(tag) 807 res = sf.ToStringPair(tag)
806 if (res[1]): 808 if (res[1]):
807 return int(res[1]) 809 return int(res[1])
808 - return None 810 + return ""
809 811
810 def GetPhotometricInterpretation(self): 812 def GetPhotometricInterpretation(self):
811 """ 813 """
812 Return string containing the photometric interpretation. 814 Return string containing the photometric interpretation.
813 Eg. "MONOCHROME2". 815 Eg. "MONOCHROME2".
814 - Return None if field is not defined. 816 + Return "" if field is not defined.
815 817
816 Critical DICOM tag (0x0028,0x0004). Cannot be edited. 818 Critical DICOM tag (0x0028,0x0004). Cannot be edited.
817 """ 819 """
@@ -821,13 +823,13 @@ class Parser(): @@ -821,13 +823,13 @@ class Parser():
821 res = sf.ToStringPair(tag) 823 res = sf.ToStringPair(tag)
822 if (res[1]): 824 if (res[1]):
823 return res[1] 825 return res[1]
824 - return None 826 + return ""
825 827
826 def GetBitsStored(self): 828 def GetBitsStored(self):
827 """ 829 """
828 Return number related to number of bits stored. 830 Return number related to number of bits stored.
829 Eg. 12 or 16. 831 Eg. 12 or 16.
830 - Return None if field is not defined. 832 + Return "" if field is not defined.
831 833
832 Critical DICOM tag (0x0028,0x0101). Cannot be edited. 834 Critical DICOM tag (0x0028,0x0101). Cannot be edited.
833 """ 835 """
@@ -837,12 +839,12 @@ class Parser(): @@ -837,12 +839,12 @@ class Parser():
837 res = sf.ToStringPair(tag) 839 res = sf.ToStringPair(tag)
838 if (res[1]): 840 if (res[1]):
839 return int(res[1]) 841 return int(res[1])
840 - return None 842 + return ""
841 843
842 def GetHighBit(self): 844 def GetHighBit(self):
843 """ 845 """
844 Return string containing hight bit. This is commonly 11 or 15. 846 Return string containing hight bit. This is commonly 11 or 15.
845 - Return None if field is not defined. 847 + Return "" if field is not defined.
846 848
847 Critical DICOM tag (0x0028,0x0102). Cannot be edited. 849 Critical DICOM tag (0x0028,0x0102). Cannot be edited.
848 """ 850 """
@@ -852,14 +854,14 @@ class Parser(): @@ -852,14 +854,14 @@ class Parser():
852 res = sf.ToStringPair(tag) 854 res = sf.ToStringPair(tag)
853 if (res[1]): 855 if (res[1]):
854 return int(res[1]) 856 return int(res[1])
855 - return None 857 + return ""
856 858
857 def GetProtocolName(self): 859 def GetProtocolName(self):
858 """ 860 """
859 Return protocol name (string). This info varies according to 861 Return protocol name (string). This info varies according to
860 manufactor and software interface. Eg. "FACE", "aFaceSpi", 862 manufactor and software interface. Eg. "FACE", "aFaceSpi",
861 "1551515/2" or "./protocols/user1.pfossa.pro". 863 "1551515/2" or "./protocols/user1.pfossa.pro".
862 - Return None if field is not defined. 864 + Return "" if field is not defined.
863 865
864 DICOM standard tag (0x0018, 0x1030) was used. 866 DICOM standard tag (0x0018, 0x1030) was used.
865 """ 867 """
@@ -869,7 +871,7 @@ class Parser(): @@ -869,7 +871,7 @@ class Parser():
869 data = str(ds.GetDataElement(tag).GetValue()) 871 data = str(ds.GetDataElement(tag).GetValue())
870 if (data): 872 if (data):
871 return data 873 return data
872 - return None 874 + return ""
873 875
874 def GetAcquisionSequence(self): 876 def GetAcquisionSequence(self):
875 """ 877 """
@@ -883,7 +885,7 @@ class Parser(): @@ -883,7 +885,7 @@ class Parser():
883 In some cases this information is presented in other forms: 885 In some cases this information is presented in other forms:
884 - HELICAL_CT 886 - HELICAL_CT
885 - SCANOSCOPE 887 - SCANOSCOPE
886 - Return None if field is not defined. 888 + Return "" if field is not defined.
887 889
888 Critical DICOM tag (0x0018, 0x0020). Cannot be edited. 890 Critical DICOM tag (0x0018, 0x0020). Cannot be edited.
889 """ 891 """
@@ -893,7 +895,7 @@ class Parser(): @@ -893,7 +895,7 @@ class Parser():
893 data = str(ds.GetDataElement(tag).GetValue()) 895 data = str(ds.GetDataElement(tag).GetValue())
894 if (data): 896 if (data):
895 return data 897 return data
896 - return None 898 + return ""
897 899
898 def GetInstitutionName(self): 900 def GetInstitutionName(self):
899 """ 901 """
@@ -916,7 +918,7 @@ class Parser(): @@ -916,7 +918,7 @@ class Parser():
916 Return mailing address (string) of the institution where the 918 Return mailing address (string) of the institution where the
917 acquisitin quipment is located. Some institutions record only 919 acquisitin quipment is located. Some institutions record only
918 the city, other record the full address. 920 the city, other record the full address.
919 - Return None if field is not defined. 921 + Return "" if field is not defined.
920 922
921 DICOM standard tag (0x0008, 0x0081) was used. 923 DICOM standard tag (0x0008, 0x0081) was used.
922 """ 924 """
@@ -926,13 +928,13 @@ class Parser(): @@ -926,13 +928,13 @@ class Parser():
926 data = str(ds.GetDataElement(tag).GetValue()) 928 data = str(ds.GetDataElement(tag).GetValue())
927 if (data): 929 if (data):
928 return data 930 return data
929 - return None 931 + return ""
930 932
931 def GetStudyInstanceUID(self): 933 def GetStudyInstanceUID(self):
932 """ 934 """
933 Return Study Instance UID (string), related to series being 935 Return Study Instance UID (string), related to series being
934 analized. 936 analized.
935 - Return None if field is not defined. 937 + Return "" if field is not defined.
936 938
937 Critical DICOM tag (0x0020, 0x000D). Cannot be edited. 939 Critical DICOM tag (0x0020, 0x000D). Cannot be edited.
938 """ 940 """
@@ -942,12 +944,12 @@ class Parser(): @@ -942,12 +944,12 @@ class Parser():
942 data = str(ds.GetDataElement(tag).GetValue()) 944 data = str(ds.GetDataElement(tag).GetValue())
943 if (data): 945 if (data):
944 return data 946 return data
945 - return None 947 + return ""
946 948
947 def GetPatientOccupation(self): 949 def GetPatientOccupation(self):
948 """ 950 """
949 Return occupation of the patient (string). 951 Return occupation of the patient (string).
950 - Return None if field is not defined. 952 + Return "" if field is not defined.
951 953
952 DICOM standard tag (0x0010,0x2180) was used. 954 DICOM standard tag (0x0010,0x2180) was used.
953 """ 955 """
@@ -957,7 +959,7 @@ class Parser(): @@ -957,7 +959,7 @@ class Parser():
957 data = str(ds.GetDataElement(tag).GetValue()) 959 data = str(ds.GetDataElement(tag).GetValue())
958 if (data): 960 if (data):
959 return data 961 return data
960 - return None 962 + return ""
961 963
962 def _GetPixelRepresentation(self): 964 def _GetPixelRepresentation(self):
963 """ 965 """
@@ -974,7 +976,7 @@ class Parser(): @@ -974,7 +976,7 @@ class Parser():
974 res = sf.ToStringPair(tag) 976 res = sf.ToStringPair(tag)
975 if (res[1]): 977 if (res[1]):
976 return int(res[1]) 978 return int(res[1])
977 - return None 979 + return ""
978 980
979 def _GetBitsAllocated(self): 981 def _GetBitsAllocated(self):
980 """ 982 """
@@ -991,7 +993,7 @@ class Parser(): @@ -991,7 +993,7 @@ class Parser():
991 993
992 if (res[1]): 994 if (res[1]):
993 return int(res[1]) 995 return int(res[1])
994 - return None 996 + return ""
995 997
996 def GetImageDataType(self): 998 def GetImageDataType(self):
997 """ 999 """
@@ -1002,14 +1004,14 @@ class Parser(): @@ -1002,14 +1004,14 @@ class Parser():
1002 - Int16 1004 - Int16
1003 - Int32 1005 - Int32
1004 - UInt16 1006 - UInt16
1005 - Return None otherwise. 1007 + Return "" otherwise.
1006 """ 1008 """
1007 repres = self._GetPixelRepresentation() 1009 repres = self._GetPixelRepresentation()
1008 1010
1009 bits = self._GetBitsAllocated() 1011 bits = self._GetBitsAllocated()
1010 1012
1011 if not bits: 1013 if not bits:
1012 - answer = None 1014 + answer = ""
1013 else: 1015 else:
1014 answer = "UInt16" 1016 answer = "UInt16"
1015 1017
@@ -1049,7 +1051,7 @@ class Parser(): @@ -1049,7 +1051,7 @@ class Parser():
1049 def GetStudyID(self): 1051 def GetStudyID(self):
1050 """ 1052 """
1051 Return string containing the Study ID. 1053 Return string containing the Study ID.
1052 - Return None if not set. 1054 + Return "" if not set.
1053 1055
1054 DICOM standard tag (0x0020,0x0010) was used. 1056 DICOM standard tag (0x0020,0x0010) was used.
1055 """ 1057 """
@@ -1058,7 +1060,7 @@ class Parser(): @@ -1058,7 +1060,7 @@ class Parser():
1058 .GetStudyID() 1060 .GetStudyID()
1059 if (data): 1061 if (data):
1060 return data 1062 return data
1061 - return None 1063 + return ""
1062 1064
1063 def GetAcquisitionGantryTilt(self): 1065 def GetAcquisitionGantryTilt(self):
1064 """ 1066 """
@@ -1080,7 +1082,7 @@ class Parser(): @@ -1080,7 +1082,7 @@ class Parser():
1080 - M: male 1082 - M: male
1081 - F: female 1083 - F: female
1082 - O: other 1084 - O: other
1083 - If not defined, return None. 1085 + If not defined, return "".
1084 1086
1085 DICOM standard tag (0x0010,0x0040) was used. 1087 DICOM standard tag (0x0010,0x0040) was used.
1086 """ 1088 """
@@ -1088,13 +1090,13 @@ class Parser(): @@ -1088,13 +1090,13 @@ class Parser():
1088 .GetPatientSex() 1090 .GetPatientSex()
1089 if (data): 1091 if (data):
1090 return data 1092 return data
1091 - return None 1093 + return ""
1092 1094
1093 def GetPatientAge(self): 1095 def GetPatientAge(self):
1094 """ 1096 """
1095 Return patient's age (integer). In case there are alpha 1097 Return patient's age (integer). In case there are alpha
1096 characters in this field, a string is returned. 1098 characters in this field, a string is returned.
1097 - If not defined field, return None. 1099 + If not defined field, return "".
1098 1100
1099 DICOM standard tag (0x0010, 0x1010) was used. 1101 DICOM standard tag (0x0010, 0x1010) was used.
1100 """ 1102 """
@@ -1106,12 +1108,12 @@ class Parser(): @@ -1106,12 +1108,12 @@ class Parser():
1106 return int(age) 1108 return int(age)
1107 except ValueError: 1109 except ValueError:
1108 return age 1110 return age
1109 - return None 1111 + return ""
1110 1112
1111 def GetPatientName(self): 1113 def GetPatientName(self):
1112 """ 1114 """
1113 Return patient's full legal name (string). 1115 Return patient's full legal name (string).
1114 - If not defined, return None. 1116 + If not defined, return "".
1115 1117
1116 DICOM standard tag (0x0010,0x0010) was used. 1118 DICOM standard tag (0x0010,0x0010) was used.
1117 """ 1119 """
@@ -1119,13 +1121,13 @@ class Parser(): @@ -1119,13 +1121,13 @@ class Parser():
1119 .GetPatientName() 1121 .GetPatientName()
1120 if (data): 1122 if (data):
1121 return data 1123 return data
1122 - return None 1124 + return ""
1123 1125
1124 def GetPatientID(self): 1126 def GetPatientID(self):
1125 """ 1127 """
1126 Return primary hospital identification number (string) 1128 Return primary hospital identification number (string)
1127 or patient's identification number (string). 1129 or patient's identification number (string).
1128 - Return None if not defined. 1130 + Return "" if not defined.
1129 1131
1130 DICOM standard tag (0x0010,0x0020) was used. 1132 DICOM standard tag (0x0010,0x0020) was used.
1131 """ 1133 """
@@ -1133,51 +1135,51 @@ class Parser(): @@ -1133,51 +1135,51 @@ class Parser():
1133 .GetPatientID() 1135 .GetPatientID()
1134 if (data): 1136 if (data):
1135 return data 1137 return data
1136 - return None 1138 + return ""
1137 1139
1138 1140
1139 def GetDimensionX(self): 1141 def GetDimensionX(self):
1140 """ 1142 """
1141 Return integer associated to X dimension. This is related 1143 Return integer associated to X dimension. This is related
1142 to the number of columns on the image. 1144 to the number of columns on the image.
1143 - Return None if not defined. 1145 + Return "" if not defined.
1144 """ 1146 """
1145 1147
1146 data = self.vtkgdcm_reader.GetOutput()\ 1148 data = self.vtkgdcm_reader.GetOutput()\
1147 .GetDimensions()[0] 1149 .GetDimensions()[0]
1148 if (data): 1150 if (data):
1149 return int(data) 1151 return int(data)
1150 - return None 1152 + return ""
1151 1153
1152 def GetDimensionY(self): 1154 def GetDimensionY(self):
1153 """ 1155 """
1154 Return integer associated to Y dimension. This is related 1156 Return integer associated to Y dimension. This is related
1155 to the number of rows on the image. 1157 to the number of rows on the image.
1156 - Return None if not defined. 1158 + Return "" if not defined.
1157 """ 1159 """
1158 data = self.vtkgdcm_reader.GetOutput()\ 1160 data = self.vtkgdcm_reader.GetOutput()\
1159 .GetDimensions()[1] 1161 .GetDimensions()[1]
1160 if (data): 1162 if (data):
1161 return int(data) 1163 return int(data)
1162 - return None 1164 + return ""
1163 1165
1164 def GetDimensionZ(self): 1166 def GetDimensionZ(self):
1165 """ 1167 """
1166 Return float value associated to Z dimension. 1168 Return float value associated to Z dimension.
1167 - Return None if not defined. 1169 + Return "" if not defined.
1168 """ 1170 """
1169 data = self.vtkgdcm_reader.GetOutput()\ 1171 data = self.vtkgdcm_reader.GetOutput()\
1170 .GetDimensions()[2] 1172 .GetDimensions()[2]
1171 if (data): 1173 if (data):
1172 return float(data) 1174 return float(data)
1173 - return None 1175 + return ""
1174 1176
1175 1177
1176 def GetEquipmentXRayTubeCurrent(self): 1178 def GetEquipmentXRayTubeCurrent(self):
1177 """ 1179 """
1178 Return float value associated to the X-ray tube current 1180 Return float value associated to the X-ray tube current
1179 (expressed in mA). 1181 (expressed in mA).
1180 - Return None if not defined. 1182 + Return "" if not defined.
1181 1183
1182 DICOM standard tag (0x0018,0x1151) was used. 1184 DICOM standard tag (0x0018,0x1151) was used.
1183 """ 1185 """
@@ -1185,13 +1187,13 @@ class Parser(): @@ -1185,13 +1187,13 @@ class Parser():
1185 .GetXRayTubeCurrent() 1187 .GetXRayTubeCurrent()
1186 if (data): 1188 if (data):
1187 return data 1189 return data
1188 - return None 1190 + return ""
1189 1191
1190 def GetExposureTime(self): 1192 def GetExposureTime(self):
1191 """ 1193 """
1192 Return float value associated to the time of X-ray tube current 1194 Return float value associated to the time of X-ray tube current
1193 exposure (expressed in s). 1195 exposure (expressed in s).
1194 - Return None if not defined. 1196 + Return "" if not defined.
1195 1197
1196 DICOM standard tag (0x0018, 0x1152) was used. 1198 DICOM standard tag (0x0018, 0x1152) was used.
1197 """ 1199 """
@@ -1199,13 +1201,13 @@ class Parser(): @@ -1199,13 +1201,13 @@ class Parser():
1199 .GetExposureTime() 1201 .GetExposureTime()
1200 if (data): 1202 if (data):
1201 return float(data) 1203 return float(data)
1202 - return None 1204 + return ""
1203 1205
1204 def GetEquipmentKVP(self): 1206 def GetEquipmentKVP(self):
1205 """ 1207 """
1206 Return float value associated to the kilo voltage peak 1208 Return float value associated to the kilo voltage peak
1207 output of the (x-ray) used generator. 1209 output of the (x-ray) used generator.
1208 - Return None if not defined. 1210 + Return "" if not defined.
1209 1211
1210 DICOM standard tag (0x0018,0x0060) was used. 1212 DICOM standard tag (0x0018,0x0060) was used.
1211 """ 1213 """
@@ -1213,13 +1215,13 @@ class Parser(): @@ -1213,13 +1215,13 @@ class Parser():
1213 .GetKVP() 1215 .GetKVP()
1214 if (data): 1216 if (data):
1215 return float(data) 1217 return float(data)
1216 - return None 1218 + return ""
1217 1219
1218 def GetImageThickness(self): 1220 def GetImageThickness(self):
1219 """ 1221 """
1220 Return float value related to the nominal reconstructed 1222 Return float value related to the nominal reconstructed
1221 slice thickness (expressed in mm). 1223 slice thickness (expressed in mm).
1222 - Return None if not defined. 1224 + Return "" if not defined.
1223 1225
1224 DICOM standard tag (0x0018,0x0050) was used. 1226 DICOM standard tag (0x0018,0x0050) was used.
1225 """ 1227 """
@@ -1235,7 +1237,7 @@ class Parser(): @@ -1235,7 +1237,7 @@ class Parser():
1235 used to reconstruct the data. This is very dependent on the 1237 used to reconstruct the data. This is very dependent on the
1236 model and the manufactor. Eg. "standard" kernel could be 1238 model and the manufactor. Eg. "standard" kernel could be
1237 written on various ways (STD, STND, Stand, STANDARD). 1239 written on various ways (STD, STND, Stand, STANDARD).
1238 - Return None if not defined. 1240 + Return "" if not defined.
1239 1241
1240 DICOM standard tag (0x0018,0x1210) was used. 1242 DICOM standard tag (0x0018,0x1210) was used.
1241 """ 1243 """
@@ -1243,7 +1245,7 @@ class Parser(): @@ -1243,7 +1245,7 @@ class Parser():
1243 .GetConvolutionKernel() 1245 .GetConvolutionKernel()
1244 if (data): 1246 if (data):
1245 return data 1247 return data
1246 - return None 1248 + return ""
1247 1249
1248 def GetEquipmentInstitutionName(self): 1250 def GetEquipmentInstitutionName(self):
1249 """ 1251 """
@@ -1263,7 +1265,7 @@ class Parser(): @@ -1263,7 +1265,7 @@ class Parser():
1263 """ 1265 """
1264 Return user defined machine name (string) used to produce exam 1266 Return user defined machine name (string) used to produce exam
1265 files. 1267 files.
1266 - Return None if not defined. 1268 + Return "" if not defined.
1267 1269
1268 DICOM standard tag (0x0008, 0x1010) was used. 1270 DICOM standard tag (0x0008, 0x1010) was used.
1269 """ 1271 """
@@ -1271,13 +1273,13 @@ class Parser(): @@ -1271,13 +1273,13 @@ class Parser():
1271 .GetStationName() 1273 .GetStationName()
1272 if (data): 1274 if (data):
1273 return data 1275 return data
1274 - return None 1276 + return ""
1275 1277
1276 def GetManufacturerModelName(self): 1278 def GetManufacturerModelName(self):
1277 """ 1279 """
1278 Return equipment model name (string) used to generate exam 1280 Return equipment model name (string) used to generate exam
1279 files. 1281 files.
1280 - Return None if not defined. 1282 + Return "" if not defined.
1281 1283
1282 DICOM standard tag (0x0008,0x1090) was used. 1284 DICOM standard tag (0x0008,0x1090) was used.
1283 """ 1285 """
@@ -1285,12 +1287,12 @@ class Parser(): @@ -1285,12 +1287,12 @@ class Parser():
1285 .GetManufacturerModelName() 1287 .GetManufacturerModelName()
1286 if (data): 1288 if (data):
1287 return data 1289 return data
1288 - return None 1290 + return ""
1289 1291
1290 def GetEquipmentManufacturer(self): 1292 def GetEquipmentManufacturer(self):
1291 """ 1293 """
1292 Return manufacturer name (string). 1294 Return manufacturer name (string).
1293 - Return None if not defined. 1295 + Return "" if not defined.
1294 1296
1295 DICOM standard tag (0x0008, 0x1010) was used. 1297 DICOM standard tag (0x0008, 0x1010) was used.
1296 """ 1298 """
@@ -1298,14 +1300,14 @@ class Parser(): @@ -1298,14 +1300,14 @@ class Parser():
1298 .GetManufacturer() 1300 .GetManufacturer()
1299 if (data): 1301 if (data):
1300 return data 1302 return data
1301 - return None 1303 + return ""
1302 1304
1303 def GetAcquisitionModality(self): 1305 def GetAcquisitionModality(self):
1304 """ 1306 """
1305 Return modality of acquisition: 1307 Return modality of acquisition:
1306 - CT: Computed Tomography 1308 - CT: Computed Tomography
1307 - MR: Magnetic Ressonance 1309 - MR: Magnetic Ressonance
1308 - Return None if not defined. 1310 + Return "" if not defined.
1309 1311
1310 DICOM standard tag (0x0008,0x0060) was used. 1312 DICOM standard tag (0x0008,0x0060) was used.
1311 """ 1313 """
@@ -1313,13 +1315,13 @@ class Parser(): @@ -1313,13 +1315,13 @@ class Parser():
1313 .GetModality() 1315 .GetModality()
1314 if (data): 1316 if (data):
1315 return data 1317 return data
1316 - return None 1318 + return ""
1317 1319
1318 1320
1319 def GetImageNumber(self): 1321 def GetImageNumber(self):
1320 """ 1322 """
1321 Return slice number (integer). 1323 Return slice number (integer).
1322 - Return None if not defined. 1324 + Return "" if not defined.
1323 1325
1324 DICOM standard tag (0x0020,0x0013) was used. 1326 DICOM standard tag (0x0020,0x0013) was used.
1325 """ 1327 """
@@ -1327,12 +1329,12 @@ class Parser(): @@ -1327,12 +1329,12 @@ class Parser():
1327 .GetImageNumber() 1329 .GetImageNumber()
1328 if (data): 1330 if (data):
1329 return int(data) 1331 return int(data)
1330 - return None 1332 + return ""
1331 1333
1332 def GetStudyDescription(self): 1334 def GetStudyDescription(self):
1333 """ 1335 """
1334 Return study description (string). 1336 Return study description (string).
1335 - Return None if not defined. 1337 + Return "" if not defined.
1336 1338
1337 DICOM standard tag (0x0008,0x1030) was used. 1339 DICOM standard tag (0x0008,0x1030) was used.
1338 """ 1340 """
@@ -1340,7 +1342,7 @@ class Parser(): @@ -1340,7 +1342,7 @@ class Parser():
1340 .GetStudyDescription() 1342 .GetStudyDescription()
1341 if (data): 1343 if (data):
1342 return data 1344 return data
1343 - return None 1345 + return ""
1344 1346
1345 def GetStudyAdmittingDiagnosis(self): 1347 def GetStudyAdmittingDiagnosis(self):
1346 """ 1348 """
@@ -1377,9 +1379,9 @@ class Parser(): @@ -1377,9 +1379,9 @@ class Parser():
1377 if (label): 1379 if (label):
1378 return label 1380 return label
1379 else: 1381 else:
1380 - return None 1382 + return ""
1381 1383
1382 - def GetSeriesDescrition(self): 1384 + def GetSeriesDescription(self):
1383 """ 1385 """
1384 Return a string with a description of the series. 1386 Return a string with a description of the series.
1385 DICOM standard tag (0x0008, 0x103E) was used. 1387 DICOM standard tag (0x0008, 0x103E) was used.
@@ -1388,9 +1390,11 @@ class Parser(): @@ -1388,9 +1390,11 @@ class Parser():
1388 ds = self.gdcm_reader.GetFile().GetDataSet() 1390 ds = self.gdcm_reader.GetFile().GetDataSet()
1389 if ds.FindDataElement(tag): 1391 if ds.FindDataElement(tag):
1390 data = str(ds.GetDataElement(tag).GetValue()) 1392 data = str(ds.GetDataElement(tag).GetValue())
  1393 + if data == "None":
  1394 + return "unnamed"
1391 if (data): 1395 if (data):
1392 return data 1396 return data
1393 - return None 1397 + return "unnamed"
1394 1398
1395 1399
1396 1400
@@ -1425,9 +1429,9 @@ class DicomWriter: @@ -1425,9 +1429,9 @@ class DicomWriter:
1425 1429
1426 def __init__(self): 1430 def __init__(self):
1427 1431
1428 - self.reader = None 1432 + self.reader = ""
1429 self.anony = gdcm.Anonymizer() 1433 self.anony = gdcm.Anonymizer()
1430 - self.path = None 1434 + self.path = ""
1431 self.new_dicom = vtkgdcm.vtkGDCMImageWriter() 1435 self.new_dicom = vtkgdcm.vtkGDCMImageWriter()
1432 reader = self.reader = gdcm.Reader() 1436 reader = self.reader = gdcm.Reader()
1433 1437
@@ -1694,11 +1698,10 @@ class Patient(object): @@ -1694,11 +1698,10 @@ class Patient(object):
1694 class Acquisition(object): 1698 class Acquisition(object):
1695 1699
1696 def __init__(self): 1700 def __init__(self):
1697 - pass 1701 + self.time = "12:34 AM"
1698 1702
1699 def SetParser(self, parser): 1703 def SetParser(self, parser):
1700 self.patient_orientation = parser.GetImagePatientOrientation() 1704 self.patient_orientation = parser.GetImagePatientOrientation()
1701 - self.series_description = parser.GetSeriesDescrition()  
1702 self.tilt = parser.GetAcquisitionGantryTilt() 1705 self.tilt = parser.GetAcquisitionGantryTilt()
1703 self.serie_number = parser.GetImageSeriesNumber() 1706 self.serie_number = parser.GetImageSeriesNumber()
1704 self.id_study = parser.GetStudyID() 1707 self.id_study = parser.GetStudyID()
@@ -1707,7 +1710,7 @@ class Acquisition(object): @@ -1707,7 +1710,7 @@ class Acquisition(object):
1707 self.acquisition_date = parser.GetAcquisitionDate() 1710 self.acquisition_date = parser.GetAcquisitionDate()
1708 self.institution = parser.GetInstitutionName() 1711 self.institution = parser.GetInstitutionName()
1709 self.date = parser.GetAcquisitionDate() 1712 self.date = parser.GetAcquisitionDate()
1710 - self.acession_number = parser.GetAccessionNumber() 1713 + self.accession_number = parser.GetAccessionNumber()
1711 self.series_description = parser.GetSeriesDescription() 1714 self.series_description = parser.GetSeriesDescription()
1712 1715
1713 class Image(object): 1716 class Image(object):
@@ -1747,5 +1750,5 @@ class Image(object): @@ -1747,5 +1750,5 @@ class Image(object):
1747 try: 1750 try:
1748 self.type = parser.GetImageType()[2] 1751 self.type = parser.GetImageType()[2]
1749 except(IndexError): 1752 except(IndexError):
1750 - self.type = None 1753 + self.type = ""
1751 1754