Comments (3)
Thank you very much. I will try this. I have one more question. The network expects the input images of the CT Scans as .png files. Could you please tell me why did you chose the input as png format images rather than DICOM or NIfTi?
from semi-supervised-lung-segmentation.
In our project, we utilized window filtering on our DICOM files to convert them into .png images, specifically for visualizing the lungs. We chose a window with a center of -500 HU (Hounsfield Units) and a width of 1500 HU. This window setting is commonly used for lung imaging because it optimally highlights the air spaces within the lungs. The air in the lungs has a much lower density compared to surrounding tissues, thus appearing darker at this specific window setting. This contrast enhancement allows for better visualization of the lung structures, including the detection of any pathological lesions or abnormalities.
This is also can make it simpler for the model to deal with 8bit images rather then working with the full range 16bits.
Below is a Python function you can use to apply window filtering to your DICOM images. This function allows you to define the center and width of the window.
def apply_window_filtering(dicom_image, window_center, window_width):
"""
Apply window filtering to a DICOM image.
Parameters:
dicom_image (numpy.ndarray): The DICOM image data.
window_center (int): The center of the window (in Hounsfield Units).
window_width (int): The width of the window (in Hounsfield Units).
Returns:
numpy.ndarray: The window filtered image.
"""
lower_bound = window_center - (window_width / 2)
upper_bound = window_center + (window_width / 2)
window_filtered_image = dicom_image.copy()
window_filtered_image[dicom_image < lower_bound] = lower_bound
window_filtered_image[dicom_image > upper_bound] = upper_bound
# Normalize to 8-bit range (0-255)
window_filtered_image = ((window_filtered_image - lower_bound) / window_width) * 255.0
window_filtered_image = window_filtered_image.astype('uint8')
return window_filtered_image
from semi-supervised-lung-segmentation.
Hi @iionichi,
I utilized the CycleGAN implementation by Aladdin Persson available here: Aladdin Persson's CycleGAN Implementation. I found it much easier to modify than the official implementation. In the training loop, I introduced an L1 loss calculation by subtracting the surroundings of the images generated from the originals. Here are the lines of code you can add ( after line 74 in the train.py) :
# You can add the L1 loss calculation at line 74 in train.py
# L1 loss body part
body_fake_healthy = get_body(fake_patho,mask)
body_healthy = get_body(healthy,mask)
body_healthy_loss = l1(body_healthy,body_fake_healthy)
"get_body is a function that computes the element-wise product between the inverted mask of the original image and the generated image."
I removed the identity loss from the calculation and switched to using 32-bit floats instead of 16-bit. You can find these details in the appendix of the paper, specifically in the "Practical Implementation" section.
from semi-supervised-lung-segmentation.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semi-supervised-lung-segmentation.