Giter Site home page Giter Site logo

dicom-contour's People

Contributors

keremturgutlu avatar marcelvanherk avatar mvallieres avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dicom-contour's Issues

Negative row index found

Hi,

Whenever i try to use the cfile2pixels method, an error pops up in the coord2pixels method, giving me a 'ValueError: negative row index found' error. Any clue why this is and how I may fix this issue?
I am using python 2.7.
this is what the stack trace looks like:
in ()
42 ########
---> 43 contour_arr = csc_matrix((np.ones_like(rows), (rows, cols)), dtype=np.int8, shape=(img_arr.shape[0],img_arr.shape[1])).toarray()
44 ########
/Users/ianbenlolo/anaconda/lib/python2.7/site-packages/scipy/sparse/compressed.pyc in init(self, arg1, shape, dtype, copy)
49 # (data, ij) format
50 from .coo import coo_matrix
---> 51 other = self.class(coo_matrix(arg1, shape=shape))
52 self._set_self(other)
53 elif len(arg1) == 3:

/Users/ianbenlolo/anaconda/lib/python2.7/site-packages/scipy/sparse/coo.pyc in init(self, arg1, shape, dtype, copy)
189 self.data = self.data.astype(dtype, copy=False)
190
--> 191 self._check()
192
193 def getnnz(self, axis=None):

/Users/ianbenlolo/anaconda/lib/python2.7/site-packages/scipy/sparse/coo.pyc in _check(self)
239 raise ValueError('column index exceeds matrix dimensions')
240 if self.row.min() < 0:
--> 241 raise ValueError('negative row index found')
242 if self.col.min() < 0:
243 raise ValueError('negative column index found')

Thank you

Different naming convention

Hi, Thanks for your work.
I have been using this package. When I call the cfile2pixels function to return a list of pairs of img_arr and contour_arr for a given contour file, I'm getting this error: FileNotFound

[Errno 2] No such file or directory: '/content/drive/MyDrive/MRIplusGd-with-Contour/1.2.840.113619.2.388.10502719.2140823.14003.1697945075.89.dcm'

The contours are in the RTSS file format, while the MRI images in my directory are named like "IMG0000000000.dcm". However, the function looks for images with a different naming convention.
How can I resolve this problem?

Pip package different from GitHub code

I first used the package by following the tutorial notebook and using the dicom_contour package from pip. This worked, but I noticed that the GitHub code (and commands) were rather different that the pip package commands.

The biggest difference I noticed was a substantial quality increase in the contour masks when going from pip package to GitHub code. As a side note thank you for the package! Your code converting the contours to pixel arrays helped me understand a lot about the metadata of the DICOM files.

Conversion from cartesian coordinates to pixel positions

First of all, thanks for your work. It helped me a lot!
I just have a question regarding the conversion from cartesian coordinates to pixel positions. I am not being able to achieve that equation intuitively. Do you have any reference or can you explain to me why is the conversion done that way?

pixel_coords = [(np.ceil((x - origin_x) / x_spacing), np.ceil((y - origin_y) / y_spacing)) for x, y, _ in coord]

I would be very appreciated!

Some Help on Contours

Hi,

I'm interested in doing the things other way around: creating contours given a mask. What software package/viewer did you use to create the contours in your example? Can you share an example study with contour file?

Sasank.

Robustness of coords2pixel

Hello. Nice scripts. I found this repo through your blog post.

When trying this out, I noticed that it is based on two unstated assumptions:

  1. The .dcm files are named exactly as %SOPInstanceUID%.dcm
  2. The RTStruct .dcm file is located at the same directory level as the CT Slice .dcm files.

As DICOM standards are very loose, those two assumptions aren't always correct. (I noticed this problem because it failed on my data sets...)

For example, in coords2pixel:

# extract the image id corresponding to given countour
# read that dicom file
img_ID = contour_dataset.ContourImageSequence[0].ReferencedSOPInstanceUID
img = dicom.read_file(path + img_ID + '.dcm')
img_arr = img.pixel_array

covert pixel to hounsfield unit

Thank you very much to your code, It help me so much.
I have one question. For pixel array, I need to covert them to hounsfield unit or not? if need, Do I need change something in contour file?

fill_contour does not exist

Hi,
in tutorial.ipynb, it mentioned fill_contour in FILLING CONTOUR ARRAYS section. This function does not exist in dicom_contour.contour. Is there any alternative function to achieve the same goal?
Thanks in advance.

SyntaxError: invalid syntax

from dicom_contour.contour import *

File "C:\Users\abc\AppData\Local\Programs\Python\Python35\lib\site-packages\dicom_contour\contour.py", line 306
plt.imsave(new_path + f'/images/image_{i}.{img_format}', X[i, :, :])

SyntaxError: invalid syntax

How do I resolve this error?

nifti to dicom rtstruct

Any chance that you can do a function in the opposite direction? When you have done segmentation and stored the mask as a nifti file, you often want to save the segmentation as a DICOM RTstruct file. I can get the contour from the mask using scikit-image, but to save it as a DICOM RTstruct file seems hard.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.