idc_helper
SuppressPrint
A class that temporarily suppresses print statements.
Methods:
Name | Description |
---|---|
__enter__ |
Sets sys.stdout to a dummy file object, suppressing print output. |
__exit__ |
Restores sys.stdout to its original value. |
Source code in fmcib/utils/idc_helper.py
__enter__()
Enter the context manager and redirect the standard output to nothing.
Returns:
Name | Type | Description |
---|---|---|
object |
The context manager object. |
Notes
This context manager is used to redirect the standard output to nothing using the open
function.
It saves the original standard output and assigns a new output destination as /dev/null
on Unix-like systems.
Source code in fmcib/utils/idc_helper.py
__exit__(exc_type, exc_val, exc_tb)
Restores the original stdout and closes the modified stdout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc_type
|
type
|
The exception type, if an exception occurred. Otherwise, None. |
required |
exc_val
|
Exception
|
The exception instance, if an exception occurred. Otherwise, None. |
required |
exc_tb
|
traceback
|
The traceback object, if an exception occurred. Otherwise, None. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/utils/idc_helper.py
build_image_seed_dict(path, samples=None)
Build a dictionary of image seeds from DICOM files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to the directory containing DICOM files. |
required |
samples
|
int
|
The number of samples to process. If None, all samples will be processed. |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame: A DataFrame containing the image seeds. |
Source code in fmcib/utils/idc_helper.py
dcmseg2nii(dcmseg_path, output_dir, tag='')
Convert a DICOM Segmentation object to NIfTI format and save the resulting segment images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dcmseg_path
|
str
|
The file path of the DICOM Segmentation object. |
required |
output_dir
|
str
|
The directory where the NIfTI files will be saved. |
required |
tag
|
str
|
An optional tag to prepend to the output file names. Defaults to "". |
''
|
Source code in fmcib/utils/idc_helper.py
download_LUNG1(path, samples=None)
Downloads the LUNG1 data manifest from Dropbox and saves it to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The directory path where the LUNG1 data manifest will be saved. |
required |
samples
|
list
|
A list of specific samples to download. If None, all samples will be downloaded. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/utils/idc_helper.py
download_RADIO(path, samples=None)
Downloads the RADIO manifest from Dropbox and saves it to the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path where the manifest file will be saved. |
required |
samples
|
list
|
A list of sample names to download. If None, all samples will be downloaded. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/utils/idc_helper.py
download_from_manifest(df, save_dir, samples)
Downloads DICOM data from IDC (Imaging Data Commons) based on the provided manifest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The manifest DataFrame containing information about the DICOM files. |
required |
save_dir
|
Path
|
The directory where the downloaded DICOM files will be saved. |
required |
samples
|
int
|
The number of random samples to download. If None, all available samples will be downloaded. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/utils/idc_helper.py
process_series_dir(series_dir)
Process the series directory and extract relevant information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series_dir
|
Path
|
The path to the series directory. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
A dictionary containing the extracted information, including the image path, patient ID, and coordinates. |