You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -31,7 +31,7 @@ We are using CT Ventilation as a Functional Imaging Modality for Lung Cancer Rad
31
31
The CT-vs-PET-Ventilation-Imaging collection is distributed under the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/).
32
32
The `CT-vs-PET-Ventilation-Imaging` dataset contains 20 lung cancer patients underwent exhale/inhale breath hold CT (BHCT), free-breathing four-dimensional CT (4DCT) and Galligas PET ventilation scans in a single session on a combined 4DPET/CT scanner.
33
33
34
-
We recomend using the BHCT scans for participants `CT-PET-VI-02` and `CT-PET-VI-03` showing very little motion between inhale and exhale (for PET scan and accompanying CT scan), and BHCT scans for participants `CT-PET-VI-05` and `CT-PET-VI-07` (the inhale and exhale CT scans), where 05 has a different number of slices between the inhale and exhale:
34
+
We recommend using the BHCT scans for participants `CT-PET-VI-02` and `CT-PET-VI-03` showing very little motion between inhale and exhale (for PET scan and accompanying CT scan), and BHCT scans for participants `CT-PET-VI-05` and `CT-PET-VI-07` (the inhale and exhale CT scans), where 05 has a different number of slices between the inhale and exhale:
35
35
36
36
* CT-PET-VI-02
37
37
```bash
@@ -160,7 +160,7 @@ Here, we provide instructions for handling multiple DICOM images, applying overl
***Load additional image using exhale scan by drag and drop**
163
-
- Images can also be opened by simply dragging them on to the itksnap window.
163
+
- Images can also be opened by simply dragging them on to the ITK-SNAP window.
164
164
In a file explorer (Finder in Mac) go to the exhale_BH_CT folder and drag any of the dicom files on to the itksnap window.
165
165
A small window will pop up asking What should itksnap do with this image?
166
166
If you select Load as Main Image it will replace the current image.
@@ -191,8 +191,8 @@ Here, we provide instructions for handling multiple DICOM images, applying overl
191
191
* To load the image as a colour overlay you need to use File->Add Another Image... (e.g., `5.000000-Thorax Insp 2.0 B70f-29873`).
192
192
* Click on Browse and select any one of the files in the PET folder (e.g., `7.000000-Thorax Exp 2.0 B70f-73355`).
193
193
* Make sure File Format is DICOM Image Series (it should be). Click Next and then Next again.
194
-
* When the image has loaded select As a semi-transparent overlay. you can also set the overlay color map here - select Hot from the dropdown menu and click Next.
195
-
* The image summary will then be displayed, along with a warning about possible loss of precision (which can be ignored). click Finish
194
+
* When the image has loaded select As a semi-transparent overlay. You can also set the overlay color map here - select Hot from the drop-down menu and click Next.
195
+
* The image summary will then be displayed, along with a warning about possible loss of precision (which can be ignored). Click Finish
@@ -221,7 +221,7 @@ Here, we provide instructions for handling multiple DICOM images, applying overl
221
221
222
222

223
223
224
-
***The Contrast tab** enables you to adjust how the image intensities are displayed for the different images. e.g. select the lung image and set the maximum value to 1000 (push enter after typing the number) and this will make the structures in the lung easier to see.
224
+
***The Contrast tab** enables you to adjust how the image intensities are displayed for the different images. e.g. Select the lung image and set the maximum value to 1000 (push enter after typing the number) and this will make the structures in the lung easier to see.
225
225
226
226

## Viewing and understanding the NifTi header with NiBabel
282
-
We are going to use the python package [NiBabel](https://nipy.org/nibabel/) to work with `NifTI` images.
283
-
We recommend to check [documentation](https://nipy.org/nibabel/#documentation) for further deatils on using nibabel library.
284
-
Please see [instructions](../_dependencies) to install such dependecies.
287
+
We are going to use the python package [NiBabel](https://nipy.org/nibabel/) to upload `NifTI` images and learn some basic properties of the image using Nibabel.
288
+
[`nibabel` api](https://nipy.org/nibabel/api.html#api) provides various image utilities, conversions methods, helpers.
289
+
We recommend to checking [documentation](https://nipy.org/nibabel/#documentation) for further deatils on using nibabel library.
290
+
Please see [instructions](https://github.com/HealthBioscienceIDEAS/Medical-Image-Registration-Short-Course/tree/main/_dependencies) to install `NiBabel` package and other dependecies.
285
291
286
292
### Loading images
287
293
1. Open terminal, activate `mirVE` environment and run python
@@ -290,15 +296,25 @@ conda activate mirVE
290
296
python
291
297
```
292
298
293
-
2. Run python commands under `*/episodes` path:
299
+
2. Importing python packages under `*/episodes` path
300
+
301
+
A NifTi image with extension `*.nii.gz` can be read using `nibabel`’s `load` function.
However, the nifti format does not require that the sform and qform specify the same
455
+
matrix, and it is not well defined what should be done when they are both provided and are
456
+
different from each other.
457
+
Often the `qform` is simply ignored and the `sform` is used, so the general advice is to only use the `sform` and set the `qform` to unknown to avoid any confusion.
396
458
```
397
459
398
-
### coordinate system
460
+
### Coordinate system
461
+
#### LPS
399
462
The original DICOM images assume the world coordinate system is LPS (i.e. values increase when moving to the left, posterior, and superior).
400
463
See this helpful information on [DICOM orientations](https://nipy.org/nibabel/dicom/dicom_orientation.html), and determine if you obtained a similar affine transform from the DICOM headers.
401
464
The values in the first two rows corresponding to the x and y dimensions would be the negative of those in the NifTi header.
402
465
403
-
### Obtaining image pixel data
404
-
```python
405
-
pixel_data=nii3ct.get_fdata()
406
-
print(pixel_data.dtype, pixel_data.shape)
407
-
#float64 (512, 512, 175)
408
-
```
466
+
#### RAS
467
+
You will notice that the diagonal elements of the affine matrix match the voxel dimensions
468
+
(as the affine matrix does not contain any rotations), but the values for the x and y
469
+
dimensions are negative. This is because the voxel indices increase as you move to the left
470
+
and posterior of the image/patient, but the nifti format assumes a RAS world coordinate
471
+
system (i.e. the values increase as you move to the right and anterior of the patient).
472
+
Therefore, the world coordinates decrease as the voxel indices increase.
* Use the `set_data_dtype` function to set the data type to float32.
437
-
438
-
Casting it to float64 prevents any integer-related errors and problems in downstream processing when using the data read by Nibabel.
497
+
### Using float64 data type
498
+
Casting image data to float64 prevents any integer-related errors and problems in downstream processing when using the data read by NiBabel.
439
499
However, this does not change the type of the image stored on disk, which as we have seen is int16 for this image, and this could still lead to downstream errors or unexpected behaviour for any processing that works directly on the images stored on disk.
440
-
Therefore, we are going to convert the image saved on disk to a floating point image.
441
-
We are going to use 32 bit rather than 64 bit floating point, as this is usually sufficiently accurate.
500
+
We are going to convert the image saved on disk to a floating point image, using the `set_data_dtype` function to set the data type to float32.
501
+
Esentially, we are going to use 32 bit rather than 64 bit floating point, as this is usually sufficiently accurate.
We are also going to set the qform to unknown as suggested above.
454
-
This also updates the corresponding fields in the header.
455
-
Use the `set_qform` function to set the `qform` code.
456
-
To just set the code and not modify the other `qform` values in the header, the first input should be None.
514
+
We are also going to set the `qform` to `unknown`, updating the corresponding fields in the header.
515
+
We use the `set_qform` function to set the `qform` code.
516
+
To just set the code and not modify the other `qform` values in the header, the first input should be `None`.
457
517
It is not necessary to modify the other `qform` values as they should be ignored when the code is set to unknown.
458
518
459
519
```python
@@ -542,8 +602,12 @@ print(nii3ct_float32.header)
542
602
#...
543
603
```
544
604
605
+
606
+
#### ITK-SNAP visualistaion of 16-bit integers vs 32 bit floats
607
+
TOADD
608
+
545
609
### Cropping data
546
-
Cropping data might offen contain background voxels which can be useful in some instances but might take up valuable RAM memory, especially for large images.
610
+
Cropping data might often contain background voxels which can be useful in some instances but might take up valuable RAM memory, especially for large images.
547
611
548
612
* Read the image data from disk using `get_fdata` and then create a new array containing a copy of the desired slices:
Automated image registrations can be prone to be failure if there are very large initial differences between the images. A manual alignment is subjective, but can provide a good enough starting guess that keeps the objective, automated registration more reliable.
682
746
* Manually aligning images
683
-
For manaual image registration in ITK-SNAP go to Tools > image registration
747
+
For manual image registration in ITK-SNAP go to Tools > image registration
684
748
685
749

0 commit comments