Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, June 18, 2007 5:02:10 AM(UTC)
themidnightwill

Groups: Registered
Posts: 21


Hello,

After getting distracted from my dicom projects, I am now picking it up again. I am tinkering with simply making a program that opens a DICOM file fromt he filesystem and displays it. Essentially, just a "Hello World" application of DICOM display - no selecting the file, etc etc.

I am having a problem with a DicomException being thrown in the following code:

private void Form1_Load(object sender, EventArgs e)
{
DicomEngine.Startup();

//open file
string file = "C:\\dcm\\test.dcm";
DicomDataSet ds = new DicomDataSet(file);

//get image, and set it as the displayed image
//theViewer is a RasterImageViewer WinForm control
RasterImage image;
image = ds.GetImage(null, 0, 0, RasterByteOrder.Gray, DicomGetImageFlags.None);
theViewer.Image = image;

DicomEngine.Shutdown();
}




I get a DicomException for the GetImage call. Here is the Stack Trace:


at Leadtools.Dicom.DicomException.CheckErrorCode(Int32 code)
at Leadtools.Dicom.DicomDataSet.GetImage(DicomElement element, Int32 index, Int32 bitsPerPixel, RasterByteOrder order, DicomGetImageFlags flags)
at TestDisplay.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Will\Local Settings\Application Data\Temporary Projects\TestDisplay\Form1.cs:line 33
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestDisplay.Program.Main() in C:\Documents and Settings\Will\Local Settings\Application Data\Temporary Projects\TestDisplay\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()





Any thoughts, ideas, etc? Am I doing something obviously wrong? FYI, the DICOM file is valid, displays in any DICOM viewer, and is readable on the file system.

Thank you,


Will
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, June 18, 2007 6:34:43 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764



 
#3 Posted : Monday, June 18, 2007 7:57:16 AM(UTC)
themidnightwill

Groups: Registered
Posts: 21


I take it you're spechless? ;-)
 
#4 Posted : Monday, June 18, 2007 8:54:47 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Naa, I just like my name alot.  Sorry for the technical difficulties, I know I wrote something, how embarrasing =).

Anyways, what was the error message as well?  The stack trace didn't have enough information to give an idea as to what went wrong.  The code looks fine at first glance.

Does the same code work for other images such as the ones that come with the toolkit? 

Can you load the same image (C:\\dcm\\test.dcm") with any of the demos?
 
#5 Posted : Monday, June 18, 2007 9:39:17 AM(UTC)
themidnightwill

Groups: Registered
Posts: 21


No problem about the blank message :-) I'm personally famous for telling people to look at email attachments... that I forgot to attach.

I was able to open the DICOM file flawlessly in "DICOM C# Main 32 Bit" demo.

I tried testing my code witht he provided file MR.DCM, and had the same problem.



Here is the full detail of the exception:



Leadtools.Dicom.DicomException was unhandled
Message="Image"
Source="Leadtools.Dicom"
StackTrace:
at Leadtools.Dicom.DicomException.CheckErrorCode(Int32 code)
at Leadtools.Dicom.DicomDataSet.GetImage(DicomElement element, Int32 index, Int32 bitsPerPixel, RasterByteOrder order, DicomGetImageFlags flags)
at TestDisplay.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\Will\My Documents\Visual Studio 2005\Projects\TestDisplay\TestDisplay\Form1.cs:line 38
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestDisplay.Program.Main() in C:\Documents and Settings\Will\My Documents\Visual Studio 2005\Projects\TestDisplay\TestDisplay\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()




Code: "Leadtools.Dicom.DicomExceptionCode.Image"
Message: "Image"
TargetSite: "{Void CheckErrorCode(Int32)}"


If there is any other info you want me to get, please just let me know.


Thanks so much for looking into this with me.

Will
 
#6 Posted : Tuesday, June 19, 2007 4:04:55 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


I tested this out and discovered that the problem is occuring because the DicomDataSet constructor is being used improperly.  In order to do its work, the DicomDataSet class needs to write out temporary files.  There are two overloads for the constructor.  The first takes no parameters and it will use the default temp directory (c:\documents and settings\[username]\local settings\temp\) and the second takes a string which tells the engine where to write the temporary files.  This string should be a path, not a file.  Since you specified a file, the engine wrote it's temporary files to that file which corrupted and eventually deleted the file.  
 
If you use either the default constructor or use a directory with the second constructor, your code will work:
 
DicomEngine.Startup();
 
//open file
string file = @"C:\Program Files\LEAD Technologies, Inc\LEADTOOLS 15\Images\MR.DCM";
string path = @"D:\junk folder\";
//DicomDataSet ds = new DicomDataSet(); //this will use the default temp directory
DicomDataSet ds = new DicomDataSet(path); //this will use path as the temp directory
 
//Load DICOM File
ds.Load(file, DicomDataSetLoadFlags.None);
 
//get image, and set it as the displayed image
//theViewer is a RasterImageViewer WinForm control
RasterImage image;
image = ds.GetImage(null, 0, 0, RasterByteOrder.Gray, DicomGetImageFlags.None);
theViewer.Image = image;
 
DicomEngine.Shutdown();
 
#7 Posted : Wednesday, June 20, 2007 10:51:45 AM(UTC)
themidnightwill

Groups: Registered
Posts: 21


Greg,

Thank you so much!! Got it all working now. I really appreciate your help.

Now onto window levels/widths :-)

Thanks,

Will
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.105 seconds.