I am using EVIL DICOM image reader, it works well with some files, but some files give me this error: destination array was not long enough check destindex and length and the array's lower bounds I can't find the original website where I have purchased the program. Would appreciate any assistance.
-
The error message is a general .NET message. Please provide more detailed information of where the error is occurring and if possible a stack trace. The "classic" Evil DICOM library can be downloaded from here. There is also a substantially re-worked new library available here.– Anders GustafssonAug 25, 2012 at 12:52
-
Thank you Anders, the error is in this line: im = new ImageMatrix(openFileDialog.FileNames, progressBar1, progressLabel);Line 22 in the EvilDicomImageReader program, Form1.cs. I did download the new DLL. Any idea how I contact the developer.– hnclAug 25, 2012 at 15:23
1 Answer
By looking at the Evil DICOM code (version 0.5.7), I assume that you are using the ImageMatrix
constructor in a way that was not entirely planned for.
The constructor you are referring to takes an array of DICOM image files, where the size of each image is supposed to be the same for all images.
Upon construction, the Image
array property is dimensioned to equal the size of one image times the length of the DICOM image array in the private method IntializeMatrix
.
Next, the constructor loops over all image files and inserts the pixel data from each file into the Image
property in the AppendImageToMatrix
method. The start position of the copied pixel data in the Image
is determined by the DICOM file ImageNumber
.
If the ImageNumber
is too high in relation to the size of the Image
array, pixel data is copied to position 0 in the Image
array.
However! If the start position is equal to the length of the Image
array, which will happen if the ImageNumber
is exactly one more than the number of files, the start position will not be modified and there will be an attempt to write to a non-existing position in the Image
array!
The line where this is happening is the fourth line in AppendImageToMatrix
, which reads:
if (offset > Image.Length) { offset = 0; }
If you are building the library yourself, you might want to change the >
operator to a >=
operator, then the application will at least not throw. Alternatively, you could consider a more fail-safe handling altogether of the pixel data copying. There is not room to elaborate on that here, though :-)
I cannot right away find the ImageMatrix
class in the updated version of Evil DICOM. However, if you run into problems with the old or the new code, consider reporting these problems on the Issues tab of the Evil DICOM Github repository.
UPDATE Note that the ImageNumber
property is equal to the DICOM attribute Instance Number, tag (0020,0013).
-
Thank you Anders, I will have to wait until Monday for one of my experience programmers; meanwhile I would like to know if Evil DICOM can read CAD Images (Animated DICOM).– hnclAug 25, 2012 at 17:55
-
I am pretty sure Evil DICOM is not capable of handling animated DICOM images, but I do not know for certain. Aug 25, 2012 at 19:49
-
To follow up: I have now also reproduced the exact same error by following the above description. By changing to
>=
the exception went away. So, the above answer was not just guess-work :-) Aug 25, 2012 at 21:33 -
Thanks again for you support. I did change offset > to offest >= in class ImageMatrix. Changed the reference in ImageReader to then new DLL, I got the same error! I am using EVILDICOM 3.5 library. Thanks– hnclAug 25, 2012 at 22:13
-
1Thank you again for your support, you are right; I rebuilt the program using the new DLL (downloaded) it it worked well, however for CAD CT image it did not. The Library 3.5 is the .Net that I have purchased in Febraury, the DLL was version 4. Thanks again Anders.– hnclAug 26, 2012 at 18:52