mosamatic2 2.0.8__py3-none-any.whl → 2.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mosamatic2 might be problematic. Click here for more details.

@@ -4,15 +4,24 @@ from mosamatic2.core.utils import (
4
4
  load_dicom,
5
5
  is_jpeg2000_compressed,
6
6
  )
7
+ from mosamatic2.core.managers.logmanager import LogManager
8
+
9
+ LOG = LogManager()
7
10
 
8
11
 
9
12
  class DicomImage(FileData):
10
13
  def load(self):
11
14
  if self.path():
12
- if is_dicom(self.path()):
13
- p = load_dicom(self.path())
15
+ p = load_dicom(self.path())
16
+ if p:
14
17
  if is_jpeg2000_compressed(p):
15
18
  p.decompress()
16
19
  self.set_object(p)
17
20
  return True
21
+ # if is_dicom(self.path()):
22
+ # p = load_dicom(self.path())
23
+ # if is_jpeg2000_compressed(p):
24
+ # p.decompress()
25
+ # self.set_object(p)
26
+ # return True
18
27
  return False
@@ -8,6 +8,9 @@ from mosamatic2.core.tasks import (
8
8
  CreatePngsFromSegmentationsTask,
9
9
  CalculateScoresTask,
10
10
  )
11
+ from mosamatic2.core.managers.logmanager import LogManager
12
+
13
+ LOG = LogManager()
11
14
 
12
15
 
13
16
  class DefaultPipeline(Pipeline):
@@ -25,6 +28,7 @@ class DefaultPipeline(Pipeline):
25
28
  ]
26
29
  def __init__(self, inputs, params, output, overwrite):
27
30
  super(DefaultPipeline, self).__init__(inputs, params, output, overwrite)
31
+ LOG.info('Found {} images to process'.format(len(os.listdir(self.input('images')))))
28
32
  model_type = self.param('model_type')
29
33
  # segmentation_task_class = SegmentMuscleFatL3Task if model_type == 'pytorch' else SegmentMuscleFatL3TensorFlowTask
30
34
  segmentation_task_class = SegmentMuscleFatL3TensorFlowTask
@@ -25,8 +25,9 @@ class CreateDicomSummaryTask(Task):
25
25
  for root, dirs, files in os.walk(patient_dir_path):
26
26
  for f in files:
27
27
  f_path = os.path.join(root, f)
28
- if is_dicom(f_path):
29
- p = load_dicom(f_path, stop_before_pixels=True)
28
+ # if is_dicom(f_path):
29
+ p = load_dicom(f_path, stop_before_pixels=True)
30
+ if p:
30
31
  series_instance_uid = p.SeriesInstanceUID
31
32
  if not series_instance_uid in data[patient_dir_name].keys():
32
33
  data[patient_dir_name][series_instance_uid] = []
mosamatic2/core/utils.py CHANGED
@@ -14,10 +14,12 @@ from pydicom.uid import (
14
14
  ExplicitVRLittleEndian, ImplicitVRLittleEndian, ExplicitVRBigEndian
15
15
  )
16
16
  from PIL import Image
17
+ from mosamatic2.core.managers.logmanager import LogManager
17
18
 
18
19
  warnings.filterwarnings("ignore", message="Invalid value for VR UI:", category=UserWarning)
19
20
 
20
21
  MUSCLE, VAT, SAT = 1, 5, 7
22
+ LOG = LogManager()
21
23
 
22
24
 
23
25
  def create_name_with_timestamp(prefix: str='') -> str:
@@ -102,17 +104,34 @@ def is_dicom(f):
102
104
  pydicom.dcmread(f, stop_before_pixels=True)
103
105
  return True
104
106
  except pydicom.errors.InvalidDicomError:
105
- return False
107
+ try:
108
+ pydicom.dcmread(f, stop_before_pixels=True, force=True)
109
+ return True
110
+ except pydicom.errors.InvalidDicomError:
111
+ pass
112
+ return False
106
113
 
107
114
 
108
115
  def load_dicom(f, stop_before_pixels=False):
109
- if is_dicom(f):
116
+ try:
110
117
  return pydicom.dcmread(f, stop_before_pixels=stop_before_pixels)
118
+ except pydicom.errors.InvalidDicomError:
119
+ try:
120
+ p = pydicom.dcmread(f, stop_before_pixels=stop_before_pixels, force=True)
121
+ if hasattr(p, 'SOPClassUID'):
122
+ if not hasattr(p.file_meta, 'TransferSyntaxUID'):
123
+ LOG.warning(f'DICOM file {f} does not have FileMetaData/TransferSyntaxUID, trying to fix...')
124
+ p.file_meta.TransferSyntaxUID = pydicom.uid.ImplicitVRLittleEndian
125
+ return p
126
+ except pydicom.errors.InvalidDicomError:
127
+ pass
111
128
  return None
112
129
 
113
130
 
114
131
  def is_jpeg2000_compressed(p):
115
- return p.file_meta.TransferSyntaxUID not in [ExplicitVRLittleEndian, ImplicitVRLittleEndian, ExplicitVRBigEndian]
132
+ if hasattr(p.file_meta, 'TransferSyntaxUID'):
133
+ return p.file_meta.TransferSyntaxUID not in [ExplicitVRLittleEndian, ImplicitVRLittleEndian, ExplicitVRBigEndian]
134
+ return False
116
135
 
117
136
 
118
137
  def is_numpy_array(value):
@@ -1 +1 @@
1
- 2.0.8
1
+ 2.0.9
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: mosamatic2
3
- Version: 2.0.8
3
+ Version: 2.0.9
4
4
  Summary:
5
5
  Author: Ralph Brecheisen
6
6
  Author-email: r.brecheisen@maastrichtuniversity.nl
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.11
10
10
  Requires-Dist: antspyx (>=0.5.4)
11
11
  Requires-Dist: dicom2nifti (>=2.6.2)
12
12
  Requires-Dist: flask (>=3.1.2)
13
+ Requires-Dist: moosez
13
14
  Requires-Dist: nibabel (>=5.3.2)
14
15
  Requires-Dist: numpy (>=1.26.4)
15
16
  Requires-Dist: openpyxl (>=3.1.5)
@@ -13,7 +13,7 @@ mosamatic2/commands/selectslicefromscans.py,sha256=3398PM2uBcxF6wpb0-c-Itp_qxoAx
13
13
  mosamatic2/constants.py,sha256=MVYMwO-x2jQSN37o3zNkRseVQ1nYRA3mLv3v_Q0Mlds,1284
14
14
  mosamatic2/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  mosamatic2/core/data/__init__.py,sha256=j9iGqUTJlGF0N0gPrzzpe_Dhv0Bj9c6FdQ1g7U-_j2g,298
16
- mosamatic2/core/data/dicomimage.py,sha256=jv1KIZBgN3SFjqgjXcPG_cx23RPauJ2TF1CzA9vj3Z8,484
16
+ mosamatic2/core/data/dicomimage.py,sha256=e4n-xw5FP_bmvjgPUSg_wPDkByYscaEm3TWAzjd935Y,786
17
17
  mosamatic2/core/data/dicomimageseries.py,sha256=OZkNi15crL8nEA-PGYsM0k9NMi2mMHRvDRePr_-czvA,849
18
18
  mosamatic2/core/data/dixonseries.py,sha256=kq9fy65MSM2XwiScqp7b3rQ09JmpyGwbG6ldZsuPRrM,516
19
19
  mosamatic2/core/data/filedata.py,sha256=hCnpizGqOpxzIADJkDS2_NSmKVLL1u49TYjSJE5UXQo,515
@@ -25,14 +25,14 @@ mosamatic2/core/managers/logmanager.py,sha256=NEaXvhl0aILjBbK710GaWanVuuNvB51HpH
25
25
  mosamatic2/core/managers/logmanagerlistener.py,sha256=Gaig07yjBnyQq9I8sN85olTEeDCDyCFQnEJdwzvmgvc,99
26
26
  mosamatic2/core/pipelines/__init__.py,sha256=Esb4TQFvY2soU2dfQPgVlhfTx1LdxYrPBiuAKDosHqA,85
27
27
  mosamatic2/core/pipelines/defaultpipeline/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- mosamatic2/core/pipelines/defaultpipeline/defaultpipeline.py,sha256=EUblRhLZXhslz9bdBmx8v9yjpgOdsHviqQZ5elK8gNQ,2901
28
+ mosamatic2/core/pipelines/defaultpipeline/defaultpipeline.py,sha256=Bme0r_shnrllWYCYDNc6cLM2fQC2yD8RJKpRdoh_6Uc,3077
29
29
  mosamatic2/core/pipelines/pipeline.py,sha256=mRxKXLKwgKDpc8R9mCI6gDKGJ2lKVxRQ__Sf0Mfn_Qc,384
30
30
  mosamatic2/core/singleton.py,sha256=FV0k_LlOCmFhlWN6gf1c2x7YXWyd8-7DsIMvOKrI6NY,224
31
31
  mosamatic2/core/tasks/__init__.py,sha256=w03AyCk2BQ6gGPBEKhtad6lt9WuwHC-nMztv7wQNwb4,759
32
32
  mosamatic2/core/tasks/calculatescorestask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
33
  mosamatic2/core/tasks/calculatescorestask/calculatescorestask.py,sha256=jEbogrEnEtMbmfQ8KOGSUdGMhdeX69Bv01-82faRIlY,6617
34
34
  mosamatic2/core/tasks/createdicomsummarytask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- mosamatic2/core/tasks/createdicomsummarytask/createdicomsummarytask.py,sha256=TebP3bI_TAUa93mp5XtnPW5NSVFMvbvb-CQAQnh6RfY,2932
35
+ mosamatic2/core/tasks/createdicomsummarytask/createdicomsummarytask.py,sha256=kcdwIBnoAXexok2j6_tF_s6gwvn2DvjLwe_VhdODpbM,2957
36
36
  mosamatic2/core/tasks/createpngsfromsegmentationstask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  mosamatic2/core/tasks/createpngsfromsegmentationstask/createpngsfromsegmentationstask.py,sha256=1UpOsp1CH668BQ0g4tALou_tFgisC306VcvqOKSDuTo,1884
38
38
  mosamatic2/core/tasks/dicom2niftitask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,7 +45,7 @@ mosamatic2/core/tasks/segmentmusclefatl3tensorflowtask/segmentmusclefatl3tensorf
45
45
  mosamatic2/core/tasks/selectslicefromscanstask/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  mosamatic2/core/tasks/selectslicefromscanstask/selectslicefromscanstask.py,sha256=1a_QHcIdS4VB39cNEBniaaDzUx3k8DcR0wCtdr8G1d0,4586
47
47
  mosamatic2/core/tasks/task.py,sha256=APPnid6dpSGkPuDqU1vm2RIMR5vkpvbP1CPHUMjympg,1691
48
- mosamatic2/core/utils.py,sha256=zh44FNOWxNKuZ4FcM7VIfMvdlzOr4AA8_PJ1r-6_83k,10855
48
+ mosamatic2/core/utils.py,sha256=iib_o_dD4hnqGIgOxLOfvMFOqLZOpt0iT_8Oarkmdjs,11723
49
49
  mosamatic2/server.py,sha256=-cZ9BPsZUXoINKqwhCHN8c59mlvzzDXzTVxsYt9au70,4644
50
50
  mosamatic2/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  mosamatic2/ui/mainwindow.py,sha256=nV9RqqSZVoVbU2opJIk7E3n4GvZWtuDETxmzwzmx4mg,13099
@@ -53,7 +53,7 @@ mosamatic2/ui/resources/icons/mosamatic2.icns,sha256=OfhC-diJTIgaNMOezxKKilGsY7m
53
53
  mosamatic2/ui/resources/icons/mosamatic2.ico,sha256=ySD3RYluHK3pgS0Eas7eKrVk_AskdLQ4qs_IT-wNhq4,12229
54
54
  mosamatic2/ui/resources/icons/spinner.gif,sha256=rvaac6GUZauHSPFSOLWr0RmLfjmtZih2Q8knQ2WP3Po,16240
55
55
  mosamatic2/ui/resources/images/body-composition.jpg,sha256=KD-BudbXwThB4lJOZZN-ad5-TZRaaZ5cKTH0Ar1TOZs,21227
56
- mosamatic2/ui/resources/VERSION,sha256=f8DsaK2OdoYvUiYLs5HB9QOzREusf-ClX8iflIy2nY8,8
56
+ mosamatic2/ui/resources/VERSION,sha256=GK-SWujODPcbTcVr82R22iPUlrjhCG6gyHU--L4NyBQ,8
57
57
  mosamatic2/ui/settings.py,sha256=YEVHYJIfNsqMO3v1pjzgh7Pih9GGoUX7S9s8S-sBNUk,2121
58
58
  mosamatic2/ui/utils.py,sha256=6bbPIrh4RJ_yhQKNZrgPbL4XeUEogjIjbk_e5c3QS5g,853
59
59
  mosamatic2/ui/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -85,7 +85,7 @@ mosamatic2/ui/widgets/panels/visualizations/slicevisualization/slicevisualizatio
85
85
  mosamatic2/ui/widgets/panels/visualizations/visualization.py,sha256=JvqTJi7cCGYK1-wrN2oURdCOBoPS2clVUyYglhkoVJg,178
86
86
  mosamatic2/ui/widgets/splashscreen.py,sha256=MS-OczOWfwwEQNQd-JWe9_Mh57css0cSQgbu973rwQo,4056
87
87
  mosamatic2/ui/worker.py,sha256=v7e3gq7MUudgpB1BJW-P7j5wurzu6-HG5m7I6WHgJp0,699
88
- mosamatic2-2.0.8.dist-info/entry_points.txt,sha256=MCUpKkgbej1clgp8EqlLQGs0BIKwGPcBPiVWLfGz9Gw,126
89
- mosamatic2-2.0.8.dist-info/METADATA,sha256=qTtZHQw_rcBOIVlCFKonPY9B2rygwNLf7-IVM8UJJzw,1467
90
- mosamatic2-2.0.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
91
- mosamatic2-2.0.8.dist-info/RECORD,,
88
+ mosamatic2-2.0.9.dist-info/entry_points.txt,sha256=MCUpKkgbej1clgp8EqlLQGs0BIKwGPcBPiVWLfGz9Gw,126
89
+ mosamatic2-2.0.9.dist-info/METADATA,sha256=ghYgnAGDjhsgKeX6PpcMuQ_Dr2ZkEI4HMXkMXBRpLW8,1489
90
+ mosamatic2-2.0.9.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
91
+ mosamatic2-2.0.9.dist-info/RECORD,,