Chris Oswald
commited on
Commit
·
cf605fe
1
Parent(s):
47626df
added load_data.ipynb tutorial
Browse files- README.md +149 -119
- SPIDER.py +1 -1
- tutorials/load_data.ipynb +0 -0
README.md
CHANGED
|
@@ -11,18 +11,41 @@ tags:
|
|
| 11 |
|
| 12 |
# Dataset Card for Spine Segmentation: Discs, Vertebrae and Spinal Canal (SPIDER)
|
| 13 |
|
| 14 |
-
The SPIDER
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
*Lumbar spine segmentation in MR images: a dataset and a public benchmark.* https://arxiv.org/abs/2306.12217.
|
| 19 |
|
| 20 |
-
|
| 21 |
-
[Grand Challenge](https://spider.grand-challenge.org/).
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Table of Contents
|
| 28 |
|
|
@@ -30,127 +53,144 @@ particular data set should be validated against the original data provided by th
|
|
| 30 |
|
| 31 |
## Dataset Description
|
| 32 |
|
| 33 |
-
- **Paper:** [Lumbar spine segmentation in MR images: a dataset and a public benchmark](https://
|
| 34 |
- **Repository:** [Zenodo](https://zenodo.org/records/8009680)
|
|
|
|
| 35 |
|
| 36 |
### Dataset Summary
|
| 37 |
|
| 38 |
The dataset includes 447 sagittal T1 and T2 MRI series collected from 218 patients across four hospitals.
|
| 39 |
Segmentation masks indicating the vertebrae, intervertebral discs (IVDs), and spinal canal are also included.
|
| 40 |
-
Segmentation masks were created manually by a medical trainee under the supervision of
|
| 41 |
-
a medical imaging expert and an experienced musculoskeletal radiologist.
|
| 42 |
|
| 43 |
In addition to MR images and segmentation masks, additional metadata (e.g., scanner manufacturer, pixel bandwidth, etc.), limited
|
| 44 |
patient characteristics (biological sex and age, when available), and radiological gradings indicating specific degenerative
|
| 45 |
changes can be loaded with the corresponding image data.
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
### Data Instances
|
| 50 |
-
|
| 51 |
-
There are 447 images and corresponding segmentation masks for 218 unique patients.
|
| 52 |
-
|
| 53 |
-
### Data Fields
|
| 54 |
-
|
| 55 |
-
The following list includes the data fields available for importing:
|
| 56 |
-
|
| 57 |
-
- Numeric representation of image
|
| 58 |
-
|
| 59 |
-
- Numeric representation of segmentation mask
|
| 60 |
-
- vertebrae
|
| 61 |
-
- intervertebral discs
|
| 62 |
-
- spinal canal
|
| 63 |
-
|
| 64 |
-
- Image characteristics
|
| 65 |
-
- number of vertebrae
|
| 66 |
-
- number of discs
|
| 67 |
-
|
| 68 |
-
- Patient characteristics
|
| 69 |
-
- biological sex
|
| 70 |
-
- age
|
| 71 |
-
|
| 72 |
-
- Scanner characteristics
|
| 73 |
-
- manufacturer
|
| 74 |
-
- manufacturer model name
|
| 75 |
-
- serial number
|
| 76 |
-
- software version
|
| 77 |
-
- echo numbers
|
| 78 |
-
- echo time
|
| 79 |
-
- echo train length
|
| 80 |
-
- flip angle
|
| 81 |
-
- imaged nucleus
|
| 82 |
-
- imaging frequency
|
| 83 |
-
- inplane phase encoding direction
|
| 84 |
-
- MR acquisition type
|
| 85 |
-
- magnetic field strength
|
| 86 |
-
- number of phase encoding steps
|
| 87 |
-
- percent phase field of view
|
| 88 |
-
- percent sampling
|
| 89 |
-
- photometric interpretation
|
| 90 |
-
- pixel bandwidth
|
| 91 |
-
- pixel spacing
|
| 92 |
-
- repetition time
|
| 93 |
-
- specific absorption rate (SAR)
|
| 94 |
-
- samples per pixel
|
| 95 |
-
- scanning sequence
|
| 96 |
-
- sequence name
|
| 97 |
-
- series description
|
| 98 |
-
- slice thickness
|
| 99 |
-
- spacing between slices
|
| 100 |
-
- specific character set
|
| 101 |
-
- transmit coil name
|
| 102 |
-
- window center
|
| 103 |
-
- window width
|
| 104 |
-
|
| 105 |
-
(TODO: Will add variable descriptions after proposal approval)
|
| 106 |
-
|
| 107 |
-
### Data Splits
|
| 108 |
|
| 109 |
-
|
|
|
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
The validation set contains 87 images distributed as follows:
|
| 118 |
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
- Standard sagittal T1 images: [x]
|
| 122 |
-
- Standard sagittal T2 images: [y]
|
| 123 |
-
- Standard sagittal T2 SPACE images: [z]
|
| 124 |
|
| 125 |
-
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
| 130 |
-
Sagittal T2 SPACE sequence images had a near isotropic spatial resolution with a voxel size of 0.90 x 0.47 x 0.47 mm.
|
| 131 |
-
[Source](https://spider.grand-challenge.org/data/)
|
| 132 |
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
-
|
| 140 |
-
-
|
| 141 |
-
-
|
| 142 |
-
-
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
-
|
| 147 |
|
| 148 |
-
|
|
|
|
|
|
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
|
| 155 |
## Additional Information
|
| 156 |
|
|
@@ -160,19 +200,9 @@ The dataset is published under a CC-BY 4.0 license: https://creativecommons.org/
|
|
| 160 |
|
| 161 |
### Citation
|
| 162 |
|
| 163 |
-
|
| 164 |
-
Job L. C. van Susante, Robert Jan Kroeze, Marinus de Kleuver, Bram van Ginneken, Nikolas Lessmann. (2023).
|
| 165 |
-
*Lumbar spine segmentation in MR images: a dataset and a public benchmark.* https://arxiv.org/abs/2306.12217.
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
# Rescale mask intensities to [0, 255] and cast as UInt8 type
|
| 171 |
-
mask = sitk.Cast(sitk.RescaleIntensity(sitk.ReadImage(mask_path)), sitk.sitkUInt8)
|
| 172 |
-
# Rescale image intensities to [0, 255] and cast as UInt8 type
|
| 173 |
-
image = sitk.Cast(sitk.RescaleIntensity(image), sitk.sitkUInt8)
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
|
|
|
| 11 |
|
| 12 |
# Dataset Card for Spine Segmentation: Discs, Vertebrae and Spinal Canal (SPIDER)
|
| 13 |
|
| 14 |
+
The SPIDER dataset contains (human) lumbar spine magnetic resonance images (MRI) and segmentation masks described in the following paper:
|
| 15 |
|
| 16 |
+
- van der Graaf, J.W., van Hooff, M.L., Buckens, C.F.M. et al. *Lumbar spine segmentation in MR images: a dataset and a public benchmark.*
|
| 17 |
+
Sci Data 11, 264 (2024). https://doi.org/10.1038/s41597-024-03090-w
|
|
|
|
| 18 |
|
| 19 |
+
Original data are available on [Zenodo](https://zenodo.org/records/8009680). More information can be found at [SPIDER Grand Challenge](https://spider.grand-challenge.org/).
|
|
|
|
| 20 |
|
| 21 |
+
<figure>
|
| 22 |
+
<img src="docs/ex1.png" alt="Example MRI Image" style="height:300px;">
|
| 23 |
+
<figcaption>Example MRI scan (at three different depths)</figcaption>
|
| 24 |
+
</figure>
|
| 25 |
+
|
| 26 |
+
<figure>
|
| 27 |
+
<img src="docs/ex2.png" alt="Example MRI Image with Segmentation Mask" style="height:300px;">
|
| 28 |
+
<figcaption>Example MRI scan with segmentation masks</figcaption>
|
| 29 |
+
</figure>
|
| 30 |
+
|
| 31 |
+
## Getting Started
|
| 32 |
+
|
| 33 |
+
First, you will need to install the following dependencies:
|
| 34 |
+
|
| 35 |
+
* `datasets >= 2.18.0`
|
| 36 |
+
* `scikit-image >= 0.19.3`
|
| 37 |
+
* `SimpleITK >= 2.3.1`
|
| 38 |
+
|
| 39 |
+
Then you can load the SPIDER dataset as follows:
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
from datasets import load_dataset
|
| 43 |
+
|
| 44 |
+
dataset = load_dataset("cdoswald/SPIDER, name="default", trust_remote_code=True)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
More detailed examples for [loading](tutorials/load_data.ipynb) the dataset with different configurations
|
| 48 |
+
and using the dataset for [segmentation tasks](tutorials/segment_anything.ipynb) are provided in the [tutorials](tutorials) folder.
|
| 49 |
|
| 50 |
## Table of Contents
|
| 51 |
|
|
|
|
| 53 |
|
| 54 |
## Dataset Description
|
| 55 |
|
| 56 |
+
- **Paper:** [Lumbar spine segmentation in MR images: a dataset and a public benchmark](https://www.nature.com/articles/s41597-024-03090-w)
|
| 57 |
- **Repository:** [Zenodo](https://zenodo.org/records/8009680)
|
| 58 |
+
- **Grand Challenge:** [SPIDER Grand Challenge](https://spider.grand-challenge.org/)
|
| 59 |
|
| 60 |
### Dataset Summary
|
| 61 |
|
| 62 |
The dataset includes 447 sagittal T1 and T2 MRI series collected from 218 patients across four hospitals.
|
| 63 |
Segmentation masks indicating the vertebrae, intervertebral discs (IVDs), and spinal canal are also included.
|
| 64 |
+
Segmentation masks were created manually by a medical trainee under the supervision of a medical imaging expert and an experienced musculoskeletal radiologist.
|
|
|
|
| 65 |
|
| 66 |
In addition to MR images and segmentation masks, additional metadata (e.g., scanner manufacturer, pixel bandwidth, etc.), limited
|
| 67 |
patient characteristics (biological sex and age, when available), and radiological gradings indicating specific degenerative
|
| 68 |
changes can be loaded with the corresponding image data.
|
| 69 |
|
| 70 |
+
### Modifications to Original Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
This version of the SPIDER dataset (i.e., available through the HuggingFace `datasets` library) differs from the original
|
| 73 |
+
data available on [Zenodo](https://zenodo.org/records/8009680) in two key ways:
|
| 74 |
|
| 75 |
+
1. Image Rescaling/Resizing: The original 3D volumetric MRI data (images and masks) are stored as .mha files and do not have a standardized height, width, depth, and image resolution.
|
| 76 |
+
To enable the data to be loaded through the HuggingFace `datasets` library, all 447 MRI series and masks are standardized to have size `(512, 512, 30)` and resolution `[0, 255]` (unisgned 8-bit integers); therefore,
|
| 77 |
+
n-dimensional interpolation is used to resize and/or rescale the images (via the `skimage.transform.resize` and `skimage.img_as_ubyte` functions).
|
| 78 |
+
If you need a different standardization, you have two options:
|
| 79 |
|
| 80 |
+
i. Pass your preferred standardization size as a `Tuple[int, int, int]` to the `resize_shape` argument in `load_dataset` (see the [LoadData Tutorial](placeholder)); OR
|
| 81 |
+
|
| 82 |
+
ii. After loading the dataset from HuggingFace, use the `SimpleITK` library to import each image using the file path of the locally cached .mha file.
|
| 83 |
+
The local cache file path is provided for each example when iterating over the dataset (again, see the [LoadData Tutorial](placeholder)).
|
|
|
|
| 84 |
|
| 85 |
+
2. Train, Validation, and Test Set: The original dataset contained 257 unique studies (i.e., patients) that were partitioned into 218 (85%) studies for the public training/validation set
|
| 86 |
+
and 39 (15%) studies for the SPIDER Grand Challenge [hidden test set](https://spider.grand-challenge.org/data/). To enable users to train, validate, and test their models prior to submitting
|
| 87 |
+
their models to the SPIDER Grand Challenge, the original 218 studies that comprised the public training/validation set were further partitioned using a 60%/20%/20% split. The original split
|
| 88 |
+
for each study (i.e., training or validation set) is recorded in the `OrigSubset` variable in the study's linked metadata.
|
| 89 |
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
## Dataset Structure
|
| 92 |
|
| 93 |
+
### Data Instances
|
| 94 |
|
| 95 |
+
There are 447 images and corresponding segmentation masks for 218 unique patients.
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
### Data Format/Fields
|
| 98 |
+
|
| 99 |
+
The format for each generated data instance is as follows:
|
| 100 |
+
|
| 101 |
+
1. **patient_id**: a unique ID number indicating the specific patient (note that many patients have more than one scan in the data)
|
| 102 |
+
|
| 103 |
+
2. **scan_type**: an indicator for whether the image is a T1-weighted, T2-weighted, or T2-SPACE MRI
|
| 104 |
+
|
| 105 |
+
3. **image**: a 3-dimensional volumetric array (height, width, depth) of values indicating pixel intensities of MRI scan
|
| 106 |
+
|
| 107 |
+
4. **mask**: a 3-dimensional volumetric array (height, width, depth) of values indicating manually segmented feature of interest
|
| 108 |
+
|
| 109 |
+
5. **image_path**: path to the local cache containing the original (non-rescaled and non-resized) MRI image
|
| 110 |
+
|
| 111 |
+
6. **mask_path**: path to the local cache containing the original (non-rescaled and non-resized) segementation mask
|
| 112 |
+
|
| 113 |
+
7. **metadata**: a dictionary of metadata of image, patient, and scanner characteristics:
|
| 114 |
+
|
| 115 |
+
- number of vertebrae
|
| 116 |
+
- number of discs
|
| 117 |
+
- biological sex
|
| 118 |
+
- age
|
| 119 |
+
- manufacturer
|
| 120 |
+
- manufacturer model name
|
| 121 |
+
- serial number
|
| 122 |
+
- software version
|
| 123 |
+
- echo numbers
|
| 124 |
+
- echo time
|
| 125 |
+
- echo train length
|
| 126 |
+
- flip angle
|
| 127 |
+
- imaged nucleus
|
| 128 |
+
- imaging frequency
|
| 129 |
+
- inplane phase encoding direction
|
| 130 |
+
- MR acquisition type
|
| 131 |
+
- magnetic field strength
|
| 132 |
+
- number of phase encoding steps
|
| 133 |
+
- percent phase field of view
|
| 134 |
+
- percent sampling
|
| 135 |
+
- photometric interpretation
|
| 136 |
+
- pixel bandwidth
|
| 137 |
+
- pixel spacing
|
| 138 |
+
- repetition time
|
| 139 |
+
- specific absorption rate (SAR)
|
| 140 |
+
- samples per pixel
|
| 141 |
+
- scanning sequence
|
| 142 |
+
- sequence name
|
| 143 |
+
- series description
|
| 144 |
+
- slice thickness
|
| 145 |
+
- spacing between slices
|
| 146 |
+
- specific character set
|
| 147 |
+
- transmit coil name
|
| 148 |
+
- window center
|
| 149 |
+
- window width
|
| 150 |
+
|
| 151 |
+
9. **rad_gradings**: radiological gradings by an expert musculoskeletal radiologist indicating specific degenerative
|
| 152 |
+
changes at all intervertebral disc (IVD) levels (see page 3 of the [original paper](https://www.nature.com/articles/s41597-024-03090-w)
|
| 153 |
+
for more details). The data are provided as a dictionary of lists; an element's position in the list indicates the IVD level. Some elements
|
| 154 |
+
are ratings while others are binary indicators. For consistency, each list will have 10 elements, but some IVD levels may not be applicable
|
| 155 |
+
to every image (which will be indicated with an empty string).
|
| 156 |
|
| 157 |
+
### Data Splits
|
| 158 |
|
| 159 |
+
The dataset is split as follows:
|
| 160 |
+
|
| 161 |
+
- Training set:
|
| 162 |
+
- 149 unique patients
|
| 163 |
+
- 304 images
|
| 164 |
+
- T1: 133 images
|
| 165 |
+
- T2: 145 images
|
| 166 |
+
- T2-SPACE: 26 images
|
| 167 |
+
- Validation set:
|
| 168 |
+
- 37 unique patients
|
| 169 |
+
- 75 images
|
| 170 |
+
- T1: 34 images
|
| 171 |
+
- T2: 34 images
|
| 172 |
+
- T2-SPACE: 7 images
|
| 173 |
+
- Test set:
|
| 174 |
+
- 32 unique patients
|
| 175 |
+
- 68 images
|
| 176 |
+
- T1: 29 images
|
| 177 |
+
- T2: 31 images
|
| 178 |
+
- T2-SPACE: 8 images
|
| 179 |
+
|
| 180 |
+
An additional hidden test set provided by the paper authors
|
| 181 |
+
(i.e., not available via HuggingFace) is available on the
|
| 182 |
+
[SPIDER Grand Challenge](https://spider.grand-challenge.org/spiders-challenge/).
|
| 183 |
|
| 184 |
+
## Image Resolution
|
| 185 |
|
| 186 |
+
> Standard sagittal T1 and T2 image resolution ranges from 3.3 x 0.33 x 0.33 mm to 4.8 x 0.90 x 0.90 mm.
|
| 187 |
+
> Sagittal T2 SPACE sequence images had a near isotropic spatial resolution with a voxel size of 0.90 x 0.47 x 0.47 mm.
|
| 188 |
+
> (https://spider.grand-challenge.org/data/)
|
| 189 |
|
| 190 |
+
Note that all images are rescaled to have pixel intensities in the range `[0, 255]` (i.e., unsigned 8-bit integers)
|
| 191 |
+
for compatibility with the HuggingFace `datasets` library. If you want to use the original resolution, you can
|
| 192 |
+
load the original images from the local cache indicated in each example's `image_path` and `mask_path` features.
|
| 193 |
+
See the data loading [tutorial](tutorials/load_data.ipynb) for more information.
|
| 194 |
|
| 195 |
## Additional Information
|
| 196 |
|
|
|
|
| 200 |
|
| 201 |
### Citation
|
| 202 |
|
| 203 |
+
- van der Graaf, J.W., van Hooff, M.L., Buckens, C.F.M. et al. Lumbar spine segmentation in MR images: a dataset and a public benchmark. Sci Data 11, 264 (2024). https://doi.org/10.1038/s41597-024-03090-w.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
+
### Disclaimer
|
| 206 |
|
| 207 |
+
I am not affiliated in any way with the aforementioned paper, researchers, or organizations. Please validate any findings using this curated dataset
|
| 208 |
+
against the original data provided by the researchers on [Zenodo](https://zenodo.org/records/8009680).)
|
SPIDER.py
CHANGED
|
@@ -129,7 +129,7 @@ _URLS = {
|
|
| 129 |
"masks":"https://zenodo.org/records/10159290/files/masks.zip",
|
| 130 |
"overview":"https://zenodo.org/records/10159290/files/overview.csv",
|
| 131 |
"gradings":"https://zenodo.org/records/10159290/files/radiological_gradings.csv",
|
| 132 |
-
"var_types": "https://huggingface.co/datasets/cdoswald/SPIDER/raw/main/
|
| 133 |
}
|
| 134 |
|
| 135 |
class CustomBuilderConfig(datasets.BuilderConfig):
|
|
|
|
| 129 |
"masks":"https://zenodo.org/records/10159290/files/masks.zip",
|
| 130 |
"overview":"https://zenodo.org/records/10159290/files/overview.csv",
|
| 131 |
"gradings":"https://zenodo.org/records/10159290/files/radiological_gradings.csv",
|
| 132 |
+
"var_types": "https://huggingface.co/datasets/cdoswald/SPIDER/raw/main/textfiles/var_types.json",
|
| 133 |
}
|
| 134 |
|
| 135 |
class CustomBuilderConfig(datasets.BuilderConfig):
|
tutorials/load_data.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|