monailabel.datastore.dicom module¶
- class monailabel.datastore.dicom.DICOMWebDatastore(client, search_filter, cache_path=None, fetch_by_frame=False, convert_to_nifti=True)[source]¶
Bases:
monailabel.datastore.local.LocalDatastore
Creates a LocalDataset object
Parameters:
- datastore_path: str
a string to the directory tree of the desired dataset
- datastore_config: str
optional file name of the dataset configuration file (by default dataset.json)
- datalist(full_path=True)[source]¶
Return a dictionary of image and label pairs corresponding to the ‘image’ and ‘label’ keys respectively
- Return type
List
[Dict
[str
,Any
]]- Returns
the {‘label’: image, ‘label’: label} pairs for training
- get_image_uri(image_id)[source]¶
Retrieve image uri based on image id
- Parameters
image_id (
str
) – the desired image’s id- Return type
str
- Returns
return the image uri
- get_label_uri(label_id, label_tag, image_id='')[source]¶
Retrieve label uri based on image id
- Parameters
label_id (
str
) – the desired label’s idlabel_tag (
str
) – the matching label’s tag
- Return type
str
- Returns
return the label uri
- get_labeled_images(label_tag=None, labels=None)[source]¶
Get all images that have a corresponding label
- Return type
List
[str
]- Returns
list of image ids List[str]
- get_unlabeled_images(label_tag=None, labels=None)[source]¶
Get all images that have no corresponding label
- Return type
List
[str
]- Returns
list of image ids List[str]
- list_images()[source]¶
Return list of image ids available in the datastore
- Return type
List
[str
]- Returns
list of image ids List[str]
- name()[source]¶
Dataset name (if one is assigned)
- Returns
Dataset name as string
- Return type
name (str)
- save_label(image_id, label_filename, label_tag, label_info, label_id='')[source]¶
Save a label for the given image id and return the newly saved label’s id
- Parameters
image_id (
str
) – the image id for the labellabel_filename (
str
) – the path to the label filelabel_tag (
str
) – the tag for the labellabel_info (
Dict
[str
,Any
]) – additional info for the label
- Return type
str
- Returns
the label id for the given label filename
- class monailabel.datastore.dicom.DICOMwebClientX(url, session=None, qido_url_prefix=None, wado_url_prefix=None, stow_url_prefix=None, delete_url_prefix=None, proxies=None, headers=None, callback=None, chunk_size=1000000)[source]¶
Bases:
dicomweb_client.web.DICOMwebClient
Instatiate client.
- Parameters
url (str) – Unique resource locator of the DICOMweb service consisting of protocol, hostname (IP address or DNS name) of the machine that hosts the service and optionally port number and path prefix
session (Union[requests.Session, None], optional) – Session required to make connections to the DICOMweb service (see
dicomweb_client.session_utils
module to create a valid session if necessary)qido_url_prefix (Union[str, None], optional) – URL path prefix for QIDO RESTful services
wado_url_prefix (Union[str, None], optional) – URL path prefix for WADO RESTful services
stow_url_prefix (Union[str, None], optional) – URL path prefix for STOW RESTful services
delete_url_prefix (Union[str, None], optional) – URL path prefix for DELETE RESTful services
proxies (Union[Dict[str, str], None], optional) – Mapping of protocol or protocol + host to the URL of a proxy server
headers (Union[Dict[str, str], None], optional) – Custom headers that should be included in request messages, e.g., authentication tokens
callback (Union[Callable[[requests.Response, ...], requests.Response], None], optional) – Callback function to manipulate responses generated from requests (see requests event hooks)
chunk_size (int, optional) – Maximum number of bytes that should be transferred per data chunk when streaming data from the server using chunked transfer encoding (used by
iter_*()
methods as well as thestore_instances()
method); defaults to10**6
bytes (1MB)
Warning
Modifies the passed session (in particular header fields), so be careful when reusing the session outside the scope of an instance.
Warning
Choose the value of chunk_size carefully. A small value may cause significant network communication and message parsing overhead.