Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amid/data/ribfrac.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
T:e9b211702bbfb33f4f526a50de1b172ba61325e867aa656c3886c7642b8e9d2fd4a94f56a612f52878ba4a5b4f6f9af8d922ec4e5be3b82842c515af5e0c2200
T:1916463710f674d1f8bb72e53252a162ff31a10a9dd0246f5088416094baac911567d60c034792efeae2cc1b76e746eb970f1e66f0fb058355149513241faaa8
38 changes: 37 additions & 1 deletion amid/ribfrac/dataset.py
Original file line number Diff line number Diff line change
@@ -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 licenses, normalize

Expand All @@ -15,14 +17,17 @@ class RibFracBase(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
----------
root : str, Path, optional
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:
Expand All @@ -31,13 +36,29 @@ class RibFracBase(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
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
Expand Down Expand Up @@ -89,6 +110,21 @@ def affine(i, _id2folder):
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)
Comment on lines +113 to +121
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use longer names, than just seg and cl. It's not clear at all what they mean


@lru_cache(None)
def _meta(_base):
file = 'RibSeg v2.xlsx'
return read_excel(_base / file)


RibFrac = normalize(
RibFracBase,
Expand Down