qmenta-client 1.1.dev1311__py3-none-any.whl → 1.1.dev1324__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.
qmenta/client/Project.py CHANGED
@@ -154,8 +154,8 @@ def wrap_search_criteria(search_criteria={}):
154
154
  'from pars_tags'
155
155
 
156
156
  file_metadata : Dict
157
- Dictionary containing the file metadata of teh search criteria
158
- exgtracted from 'pars_[dicom]_KEY'
157
+ Dictionary containing the file metadata of the search criteria
158
+ extracted from 'pars_[dicom]_KEY'
159
159
  """
160
160
 
161
161
  # The keys not included bellow apply to the whole session.
@@ -829,10 +829,12 @@ class Project:
829
829
  analysis = self.list_analysis(limit)
830
830
  return [{"name": a["name"], "id": a["out_container_id"]} for a in analysis]
831
831
 
832
- def list_container_files(self, container_id):
832
+ def list_container_files(
833
+ self,
834
+ container_id,
835
+ ):
833
836
  """
834
837
  List the name of the files available inside a given container.
835
-
836
838
  Parameters
837
839
  ----------
838
840
  container_id : str or int
@@ -852,12 +854,73 @@ class Project:
852
854
  except errors.PlatformError as e:
853
855
  logging.getLogger(logger_name).error(e)
854
856
  return False
855
-
856
- try:
857
- return content["files"]
858
- except KeyError:
857
+ if "files" not in content.keys():
859
858
  logging.getLogger(logger_name).error("Could not get files")
860
859
  return False
860
+ return content["files"]
861
+
862
+ def list_container_filter_files(
863
+ self,
864
+ container_id,
865
+ modality="",
866
+ metadata_info={},
867
+ tags=[]
868
+ ):
869
+ """
870
+ List the name of the files available inside a given container.
871
+ search condition example:
872
+ "metadata": {"SliceThickness":1},
873
+ }
874
+ Parameters
875
+ ----------
876
+ container_id : str or int
877
+ Container identifier.
878
+
879
+ modality: str
880
+ String containing the modality of the files being filtered
881
+
882
+ metadata_info: dict
883
+ Dictionary containing the file metadata of the files being filtered
884
+
885
+ tags: list[str]
886
+ List of strings containing the tags of the files being filtered
887
+
888
+ Returns
889
+ -------
890
+ selected_files: list[str]
891
+ List of file names (strings)
892
+ """
893
+ content_files = self.list_container_files(container_id)
894
+ content_meta = self.list_container_files_metadata(container_id)
895
+ selected_files = []
896
+ for index, file in enumerate(content_files):
897
+ metadata_file = content_meta[index]
898
+ tags_file = metadata_file.get("tags")
899
+ tags_bool = [tag in tags_file for tag in tags]
900
+ info_bool = []
901
+ if modality == "":
902
+ modality_bool = True
903
+ else:
904
+ modality_bool = modality == metadata_file["metadata"].get(
905
+ "modality"
906
+ )
907
+ for key in metadata_info.keys():
908
+ meta_key = (
909
+ (
910
+ metadata_file.get("metadata") or {}
911
+ ).get("info") or {}).get(
912
+ key
913
+ )
914
+ if meta_key is None:
915
+ logging.getLogger(logger_name).warning(
916
+ f"{key} is not in file_info from file {file}"
917
+ )
918
+ info_bool.append(
919
+ metadata_info[key] == meta_key
920
+ )
921
+ if all(tags_bool) and all(info_bool) and modality_bool:
922
+ selected_files.append(file)
923
+ return selected_files
861
924
 
862
925
  def list_container_files_metadata(self, container_id):
863
926
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qmenta-client
3
- Version: 1.1.dev1311
3
+ Version: 1.1.dev1324
4
4
  Summary: Python client lib to interact with the QMENTA platform.
5
5
  Author: QMENTA
6
6
  Author-email: dev@qmenta.com
@@ -1,10 +1,10 @@
1
1
  qmenta/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
2
2
  qmenta/client/Account.py,sha256=MEljEy9cmg2uP2FG1d3TZAgfj66EE2_3PQAZ9rvpCXY,9647
3
3
  qmenta/client/File.py,sha256=ZgvSqejIosUt4uoX7opUnPnp5XGEaJNMRwFC0mQVB8k,5344
4
- qmenta/client/Project.py,sha256=u2fGizvjr3uU9476m_tV0padhlKxqcSR7i2xp07jrps,68234
4
+ qmenta/client/Project.py,sha256=9a6v7-H6BxU-2EykaWnFhW61GZijDB-XWsYzPdzWxz4,70398
5
5
  qmenta/client/Subject.py,sha256=lhxxVdQ6d-GNoQC8mrJwa4L1f44nJc4PcJtDspmKN7I,8756
6
6
  qmenta/client/__init__.py,sha256=AjTojBhZeW5nl0i605KS8S1Gl5tPNc1hdzD47BGNfoI,147
7
7
  qmenta/client/utils.py,sha256=5DK2T_HQprrCwLS0Ycm2CjseaYmAUKaJkJvYoW-Rqzc,2479
8
- qmenta_client-1.1.dev1311.dist-info/METADATA,sha256=7Zesw_sWgPMQYv9ByAllGzdmTCCQcQo4u-o4Q2EHyso,672
9
- qmenta_client-1.1.dev1311.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
10
- qmenta_client-1.1.dev1311.dist-info/RECORD,,
8
+ qmenta_client-1.1.dev1324.dist-info/METADATA,sha256=yDhr3jCEwhPFFSWqIdJUeaZtj10Y3GXyEbAq7fDj7UQ,672
9
+ qmenta_client-1.1.dev1324.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
10
+ qmenta_client-1.1.dev1324.dist-info/RECORD,,