-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mask and dicom both? #10
Comments
Hello Anne! Yes, it segments the bronchopulmonary segments, but you need the mask for this. The original DICOM data set is not necessary. The mask is essentially a 3D numpy array where a 1 is written where there is bronchus, and a 0 elsewhere. More details in the README. Hope this helps! |
Brutenis, thank you very much for answering my questions in such a timely manner. I have a doubt. If I need to segment a patient's bronchopulmonary segment, do I need to correspond to the patient's template image? Still like deep learning, after training this model, I only need to input the original image of the patient to get the segmentation of bronchopulmonary. |
In the process of reproduction, I want to use stage-01 as the input. When I use the file airway/image_processing/save_images_as_npz.py to convert the original dicom data into a numpy array, the following problem appears. How can I solve it? ERROR: Insufficient count of input/output paths supplied! |
You can use the script The script you used expects two parameters, the input path and the output path, so you could call it with both as well. You could also create the model with a simple script, but this of course depends on your bronchus mask format. See below for an example how this could be done. In this case all from pathlib import Path
import numpy as np
import pydicom
image_files = Path().cwd().glob('IMG*') # Our data was called IMG1 to (around) IMG700
sort_ascending = sorted(image_files, key=lambda f: int(f.name[3:]))
layers = []
for image_name in sort_ascending:
# Our DICOM image contained -10000 for empty voxels, and some value around 100 for bronchus
im = pydicom.dcmread(image_name).pixel_array # Read the DICOM image
im = np.add(im, 10000) # Shift all values to between 0 and around 11000
im = np.clip(im, 0, 1) # Clip all values to between 0 and 1
layers.append(im) # Append current layer to
model = np.stack(layers) # Stack all layers into a single array
print(model.shape) # Should be around 700 x 512 x 512
np.savez_compressed("model", model) # Save it as a compressed numpy array I agree that currently this is a bit convoluted, I'll try to simplify the process and add a tutorial for this within the next two weeks or so. |
Thank you very much for your patient answers, my stage-01 has run through, and I am currently debugging stage-02. I read the readme of the project again, and also read other people’s questions. I need to confirm two points with you: First: If my mask does not segment the lung lobes, bronchus, arteries, and veins like the mask in your project, but only extracts the bronchus (that is, the bronchus is 1 and other places are 0), Can I use my mask to divide the bronchus into 18 segments? Second: |
Hello, developer, I put the bronchial mask (bronchial area is 1, and the rest is 0) into the stage-01 folder. When stage-02 is run, it passes successfully, but when stage-04 is run, an error message appears. Is the error reported because my slice thickness is not uniform? You mentioned in the readme that the slicer thickness in all directions must be the same. I am confused about the slice thickness in all directions. Is there any difference between the slice thickness and the spacing? I don’t know how to unify the slice thickness in all directions |
Yes, I just tested it with only the bronchus mask and it worked well (encountered a bug in stage 60, but this shouldn't be a problem for now. I'll fix it soon though).
Yes, this is the directory where your compressed mask is stored, and looks like this:
And no DICOM data is needed at this point, so it should work.
That's unfortunate, could you run it with the Hope it works for you! Excited to see it work on someone else's data! |
I just re-run the program after unifying the slice thicknesses, and I still get an error at stage-04. I tried to use |
I printed out my compressed mask array, and the result showed that the value of most positions is "false", a few positions are "true", not "0" and "1". Is it the data type in the array that caused stage-04 to report an error? |
True and False should work, I just tested it. I think numpy doesn't really differentiate between True/False and 1/0. Are you sure there is a mistake if it doesn't print an error? Because otherwise some things will definitely be printed. If your data isn't private, I could take a look at it if you can send me the model.npz (bronchus mask only would be enough). Also, I've pushed some updates for the later stages. |
Can you see the pictures I uploaded? The picture shows that an error occurred when processing stage-04. |
I put the model.npz file into a folder, compressed it into a zip format and uploaded it, you can see if it can be decompressed normally, and use |
The zip seems to be empty, it only contains a folder. You could send me an E-Mail to brutenis [at] gmail.com with the model as well. |
Ok, I have just sent the model.npz data to you via [email protected], please check it, thank you very much |
It works for me without errors (even stage-04). I've included a rendered version of your model: Although the 0th axis was flipped (i.e. it was upside-down), I flipped it like this: import numpy as np
model = np.load("original_model.npz")['arr_0']
model = model.astype(np.uint8)
model = np.flip(model, axis=0)
np.savez_compressed("model.npz", model) No segments were detected because the bronchus mask currently doesn't have enough detail, it does contain a few splits though, so that works. For the error, maybe you have more folders than necessary? Make sure that each stage folder contains patient folders which contain the models, if there are other folders delete them. And can you try again with the |
You could also try setting |
Folder structure looks exactly how it should. But I can't seem to replicate the error with your model on my part, it works even without flipping and without converting it to to I've pushed a few updates, can you try stage-04 again after pulling? I've also sent you stage-04 via email, perhaps you can try whether the latter stages work if the other stuff does not. |
I pulled down your updated project and ran it again. Stage-04 can run through without error, hahaha, thank you very much, I will try the following steps |
Yes, the problem is that the data does not have enough detail. I had previously attached an image of your 3D model, it lacks the actual segments which should be classified. Compare it with the one shown in the README. So stage-11 fails because there are no segments. Although it should not crash, that is correct. To create the 3d model you can run this command: |
I've emailed the doctor who gave us the data whether I'm allowed to send to it to anyone, but he told me I should not, at least for now. Maybe there are some public bronchus masks available meanwhile? Sorry about all the errors you have been experiencing, but this one should be harmless. If you have blender installed you can still try to visualize it by running |
Ah, maybe blender is not accessible in the current environment? You could try changing |
Blender is a 3D visualisation program which has to be installed via the package manager: I'll look into the error in stage 02. Edit: I've fixed it I think. You can git pull and try again. |
The optimal way would be to mount the folder structure in your local computer and to add the path in the local For example, mounting it via Then install airway locally as well, including blender and its dependencies. Now change the path in the local Now you should be able to run the same |
Yes, I get those errors too, but this is because both models are either empty or nearly empty.
And Can you try creating a connected voxel model? Meanwhile I'll see if I can generate some fake data for testing purposes. |
Model1 looks great! You just need to flip it, that's why it crashes. (Flipping with the same script as I had mentioned above) Here is what it looks like: Model2 doesn't look as good (I also flipped it): After flipping stage-11 works fine as well. But you don't need it for visualization. To visualize only these are required: I also now added a fake bronchus model based on the data I have. It looks a bit funny but all stages should work with it. You can either use it manually in |
Hello, developer, this project is very meaningful. I am also studying the segmentation of bronchopulmonary. I want to know if your project can be used for segmentation of bronchopulmonary?
If it can be used for bronchopulmonary segmentation, is it necessary to have both the mask and the original dicom data?
The text was updated successfully, but these errors were encountered: