From d373867044c3be752cad409b1d8ce23bb54e7153 Mon Sep 17 00:00:00 2001 From: Aleksey Leonov Date: Thu, 14 Sep 2023 12:58:10 +0300 Subject: [PATCH 1/3] added ribseg annotations --- amid/data/ribfrac.hash | 2 +- amid/ribfrac/dataset.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/amid/data/ribfrac.hash b/amid/data/ribfrac.hash index 284ee3ac..c44c4537 100644 --- a/amid/data/ribfrac.hash +++ b/amid/data/ribfrac.hash @@ -1 +1 @@ -T:e9b211702bbfb33f4f526a50de1b172ba61325e867aa656c3886c7642b8e9d2fd4a94f56a612f52878ba4a5b4f6f9af8d922ec4e5be3b82842c515af5e0c2200 \ No newline at end of file +T:1916463710f674d1f8bb72e53252a162ff31a10a9dd0246f5088416094baac911567d60c034792efeae2cc1b76e746eb970f1e66f0fb058355149513241faaa8 \ No newline at end of file diff --git a/amid/ribfrac/dataset.py b/amid/ribfrac/dataset.py index 152a6b8a..bc8146f2 100644 --- a/amid/ribfrac/dataset.py +++ b/amid/ribfrac/dataset.py @@ -1,9 +1,11 @@ +from functools import lru_cache from pathlib import Path import nibabel import numpy as np from connectome import Source, meta from connectome.interface.nodes import Silent +from pandas import read_excel from ..internals import checksum, licenses, register @@ -24,6 +26,10 @@ class RibFrac(Source): both clinical research for automatic rib fracture detection and diagnoses, and engineering research for 3D detection, segmentation and classification. + Annotations are from available RibSeg segmentation benchmark + (https://ribfrac.grand-challenge.org/). Dataset contains all 660 segmentaion + masks (seg) and centerlines (cl). + Parameters ---------- @@ -31,7 +37,6 @@ class RibFrac(Source): path to the folder containing the raw downloaded archives. If not provided, the cache is assumed to be already populated. - Notes ----- Data downloaded from here: @@ -40,13 +45,29 @@ class RibFrac(Source): https://doi.org/10.5281/zenodo.3893495 -- val (80 images) https://zenodo.org/record/3993380 -- test (160 images without annotation) + Annotations downloaded from here: + At the time of September 2023 the dataset was pre-launched, for details go to https://github.com/M3DV/RibSeg + dataset: https://drive.google.com/file/d/1ZZGGrhd0y1fLyOZGo_Y-wlVUP4lkHVgm/view?usp=sharing + description table: https://docs.google.com/spreadsheets/d/1lz9liWPy8yHybKCdO3BCA9K76QH8a54XduiZS_9fK70/edit?usp=sharing + example: + seg: seg = nibabel.load(file name).get_fdata() + # seg is a np array / volume of (512,512,N) with rib labels + cl: cl = np.load(file name)['cl'] + # cl is a np array of (24,500,3), each rib contains 500 points References ---------- + Data: Jiancheng Yang, Liang Jin, Bingbing Ni, & Ming Li. (2020). RibFrac Dataset: A Benchmark for Rib Fracture Detection, Segmentation and Classification + + Annotation: + Liang Jin, Shixuan Gu, Donglai Wei, Jason Ken Adhinarta, + Kaiming Kuang, Yongjie Jessica Zhang, et al (2022) + RibSeg v2: A Large-scale Benchmark for + Rib Labeling and Anatomical Centerline Extraction """ _root: str @@ -97,3 +118,18 @@ def affine(i, _id2folder): """The 4x4 matrix that gives the image's spatial orientation""" image_path = _id2folder[i] / f'{i}-image.nii.gz' return nibabel.load(image_path).affine + + def seg(i, _base): + seg_path = _base / 'seg' / f'{i}-rib-seg.nii.gz' + ribs = nibabel.load(seg_path).get_fdata() + return ribs.astype(np.int16) + + def cl(i, _base): + cl_path = _base / 'cl' / f'{i}.npz' + cl = np.load(cl_path)['cl'] + return cl.astype(np.int16) + + @lru_cache(None) + def _meta(_base): + file = 'RibSeg v2.xlsx' + return read_excel(_base / file) From 5c8b1a1dbb41263edcdd84112295011b10ed711c Mon Sep 17 00:00:00 2001 From: Aleksey Leonov Date: Tue, 3 Oct 2023 12:32:05 +0300 Subject: [PATCH 2/3] dev pulled for ribfrac --- amid/ribfrac/dataset.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/amid/ribfrac/dataset.py b/amid/ribfrac/dataset.py index bc8146f2..c99cfb97 100644 --- a/amid/ribfrac/dataset.py +++ b/amid/ribfrac/dataset.py @@ -7,19 +7,10 @@ from connectome.interface.nodes import Silent from pandas import read_excel -from ..internals import checksum, licenses, register +from ..internals import licenses, normalize -@register( - body_region='Chest', - license=licenses.CC_BYNC_40, - link='https://ribfrac.grand-challenge.org', - modality='CT', - raw_data_size='77.8 G', - task='Segmentation', -) -@checksum('ribfrac') -class RibFrac(Source): +class RibFracBase(Source): """ RibFrac dataset is a benchmark for developping algorithms on rib fracture detection, segmentation and classification. We hope this large-scale dataset could facilitate @@ -133,3 +124,16 @@ def cl(i, _base): def _meta(_base): file = 'RibSeg v2.xlsx' return read_excel(_base / file) + + +RibFrac = normalize( + RibFracBase, + 'RibFrac', + 'ribfrac', + body_region='Chest', + license=licenses.CC_BYNC_40, + link='https://ribfrac.grand-challenge.org', + modality='CT', + raw_data_size='77.8 G', + task='Segmentation', +) From 5f064a9c0f459561fed13adce2122c94a7c019b4 Mon Sep 17 00:00:00 2001 From: Aleksey Leonov Date: Tue, 3 Oct 2023 12:40:57 +0300 Subject: [PATCH 3/3] made one line shorted --- amid/ribfrac/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amid/ribfrac/dataset.py b/amid/ribfrac/dataset.py index c99cfb97..ff4ae5aa 100644 --- a/amid/ribfrac/dataset.py +++ b/amid/ribfrac/dataset.py @@ -39,7 +39,7 @@ class RibFracBase(Source): Annotations downloaded from here: At the time of September 2023 the dataset was pre-launched, for details go to https://github.com/M3DV/RibSeg dataset: https://drive.google.com/file/d/1ZZGGrhd0y1fLyOZGo_Y-wlVUP4lkHVgm/view?usp=sharing - description table: https://docs.google.com/spreadsheets/d/1lz9liWPy8yHybKCdO3BCA9K76QH8a54XduiZS_9fK70/edit?usp=sharing + table: https://docs.google.com/spreadsheets/d/1lz9liWPy8yHybKCdO3BCA9K76QH8a54XduiZS_9fK70/edit?usp=sharing example: seg: seg = nibabel.load(file name).get_fdata()