Pre-existing labels do not get imported
See original GitHub issueDescribe the bug Pre-existing labels will not be imported if the file extension differs from the file extension of the corresponding image.
To Reproduce Steps to reproduce the behavior:
- Put example image file in /data, i.e. /data/patient_0001.dcm
- Put example label file in /data/labels/final, that has another file extensions, i.e. /data/labels/final/patient_0001.nii.gz
- Start monailabel server to initiate file parsing/import procedure,
monailabel start_server --app app --studies /data
- Pre-existing label file is not imported, server log shows the following:
[2021-12-10 08:55:32,700] [436] [MainThread] [INFO] (monailabel.datastore.local:125) - Auto Reload: True; Extensions: ['*.dcm', '*.nii.gz', '*.nii', '*.nrrd']
[2021-12-10 08:55:32,711] [436] [MainThread] [INFO] (monailabel.datastore.local:551) - Adding New Image: patient_0001 => patient_0001.dcm
[2021-12-10 08:55:32,759] [436] [MainThread] [INFO] (monailabel.datastore.local:581) - Adding New Label: final => patient_0001 => patient_0001.nii.gz
[2021-12-10 08:55:32,763] [436] [MainThread] [ERROR] (uvicorn.error:89) - Traceback (most recent call last):
File "/opt/conda/lib/python3.8/site-packages/starlette/routing.py", line 540, in lifespan
async for item in self.lifespan_context(app):
File "/opt/conda/lib/python3.8/site-packages/starlette/routing.py", line 481, in default_lifespan
await self.startup()
File "/opt/conda/lib/python3.8/site-packages/starlette/routing.py", line 516, in startup
await handler()
File "/opt/conda/lib/python3.8/site-packages/monailabel/app.py", line 99, in startup_event
instance = app_instance()
File "/opt/conda/lib/python3.8/site-packages/monailabel/interfaces/utils/app.py", line 51, in app_instance
app = c(app_dir=app_dir, studies=studies, conf=conf)
File "/workspace/code/main.py", line 43, in __init__
super().__init__(
File "/opt/conda/lib/python3.8/site-packages/monailabel/interfaces/app.py", line 85, in __init__
self._datastore: Datastore = self.init_datastore()
File "/opt/conda/lib/python3.8/site-packages/monailabel/interfaces/app.py", line 136, in init_datastore
return LocalDatastore(
File "/opt/conda/lib/python3.8/site-packages/monailabel/datastore/local.py", line 142, in __init__
self._reconcile_datastore()
File "/opt/conda/lib/python3.8/site-packages/monailabel/datastore/local.py", line 530, in _reconcile_datastore
invalidate += self._add_non_existing_labels(tag)
File "/opt/conda/lib/python3.8/site-packages/monailabel/datastore/local.py", line 586, in _add_non_existing_labels
"checksum": file_checksum(os.path.join(self._datastore.image_path(), name)),
File "/opt/conda/lib/python3.8/site-packages/monailabel/utils/others/generic.py", line 112, in file_checksum
with open(file, "rb") as content:
FileNotFoundError: [Errno 2] No such file or directory: '/workspace/data/./patient_0001.nii.gz'
[2021-12-10 08:55:32,763] [436] [MainThread] [ERROR] (uvicorn.error:35) - Application startup failed. Exiting.
Expected behavior Pre-existing label file should get imported although the file extension differs from the file extension of the corresponding image.
Proposed solution Change line 586 in MONAILabel/monailabel/datastore/local.py
"checksum": file_checksum(os.path.join(self._datastore.label_path(), name)),`
self._datastore.image_path() may be changed to self._datastore.label_path()
Should I create a pull request?
Environment docker: projectmonai/monailabel
python -c 'import monai; monai.config.print_debug_info()'
================================
Printing MONAI config...
================================
MONAI version: 0.8.0+4.g8a1454a7
Numpy version: 1.21.2
Pytorch version: 1.10.0a0+0aef44c
MONAI flags: HAS_EXT = True, USE_COMPILED = False
MONAI rev id: 8a1454a75de71ee50099d0302ce5146c900cee09
Optional dependencies:
Pytorch Ignite version: 0.4.6
Nibabel version: 3.2.1
scikit-image version: 0.18.3
Pillow version: 8.4.0
Tensorboard version: 2.6.0
gdown version: 4.2.0
TorchVision version: 0.11.0a0
tqdm version: 4.62.3
lmdb version: 1.2.1
psutil version: 5.8.0
pandas version: 1.3.4
einops version: 0.3.2
transformers version: 4.12.5
mlflow version: 1.21.0
For details about installing the optional dependencies, please visit:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies
================================
Printing system config...
================================
System: Linux
Linux version: Ubuntu 20.04.3 LTS
Platform: Linux-5.10.76-linuxkit-x86_64-with-glibc2.10
Processor: x86_64
Machine: x86_64
Python version: 3.8.12
Process name: python
Command: ['python', '-c', 'import monai; monai.config.print_debug_info()']
Open files: []
Num physical CPUs: 2
Num logical CPUs: 2
Num usable CPUs: 2
CPU usage (%): [7.3, 25.3]
CPU freq. (MHz): 3200
Load avg. in last 1, 5, 15 mins (%): [14.5, 30.0, 34.0]
Disk usage (%): 46.1
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 1.9
Available memory (GB): 1.1
Used memory (GB): 0.4
================================
Printing GPU config...
================================
Num GPUs: 0
Has CUDA: False
cuDNN enabled: True
cuDNN version: 8204
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
how to import pre-generated labels? · Issue #464 - GitHub
Is it possible to import pre-existing labels (ideally in YOLO format) so that I can use labelImg to quickly validate / edit them...
Read more >Label sets - LimeSurvey Manual
If you have previously created a label set, then LimeSurvey will not allow you import a similar external label set unless you turn...
Read more >Bringing existing resources into CloudFormation management
Import operations don't allow new resource creations, resource deletions, or changes to property configurations. Each resource to import must have a ...
Read more >Importation of Prescription Drugs - Federal Register
These entries must be filed as formal entries. If an eligible prescription drug that is imported or offered for import does not comply...
Read more >Export into pre-existing schema - Ask TOM
I have a database I want to export user schema and import into another database for that we need to drop existing users...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just raised PR #557. Could be closed. Thank you.
Please feel free to raise a PR… at the end… its all open source