Thanks Dan. I tried this. It still doesn't work.Now I get an unhandled exception at 0x00406515 in my exe file.<br><br><div><span class="gmail_quote">On 1/11/07, <b class="gmail_sendername">Daniel Mace</b> <<a href="mailto:dlm19@duke.edu">
dlm19@duke.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Ashish,<br><br>I think I ran into the same problem a while ago. I ended up replacing
<br>the code with the following<br>-----------------------------------------<br>const vector<string> &fileNames = nameGenerator->GetInputFileNames();<br>-----------------------------------------<br><br>and then set the file names by calling
<br><br>---------------------------------------------<br>reader->SetFileName( fileNames[i].c_str());<br>---------------------------------------------<br><br>More of a quick fix for me (as I was returning to C++ after an 8 year
<br>hiatus), and I'm sure there is something more efficient. Try making<br>that change and let me know if it works.<br><br>Cheers,<br>Dan<br><br>Ashish Singh wrote:<br>> Thanks for replying Dan. Yes that's what it is,
<br>> reader->SetFileName(fileNames[fni]).<br>> The fname was a typo in my previous message,sorry for that. It doesn't<br>> work with<br>> reader->SetFileName(fileNames[fni])<br>><br>> The exact error message is a pop up box, titled Microsft Visual C++
<br>> debug Library. It reads-<br>> ---------<br>> Debug Assertion Failed!<br>> Program:...<br>> File: C:\program Files(x86)\Microsft Visual Studio 8\VC\include\vector<br>> Line: 756<br>><br>> Expression: vector subscript out of range
<br>><br>> For information on how your program can cause assertion failure, see<br>> the Visual C++ documentation on asserts.<br>><br>> abort-retry-ignore<br>> --------<br>><br>> Do you know what is going wrong here?
<br>><br>> Thanks,<br>> Ashish<br>><br>> On 1/11/07, *Daniel Mace* <<a href="mailto:dlm19@duke.edu">dlm19@duke.edu</a> <mailto:<a href="mailto:dlm19@duke.edu">dlm19@duke.edu</a>>> wrote:<br>>
<br>> Ashish,<br>><br>> What's the exact error message that it gives you? Also, where do you<br>> set "fname". perhaps it should be:<br>> -----------<br>> reader->SetFileName(fileNames[fni])
<br>> --------<br>> unless you set fname somewhere else in the code that isn't present.<br>><br>> Cheers,<br>> Dan<br>><br>> Ashish Singh wrote:<br>> > Hi,<br>> >
<br>> > I am a newbie to ITK. I was trying to read a set of dicom images<br>> from<br>> > a directory and then use reader->update() to process each one of<br>> them<br>> > one after the other. But the reader->update() gives me an error
<br>> after<br>> > reading the first image. Can anyone please tell me how to fix this<br>> > problem?<br>> ><br>> > This is what my code looks like. It is not the complete code,
<br>> but only<br>> > the relevant part of it.<br>> > ---------------<br>> > typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br>> > NamesGeneratorType::Pointer nameGenerator =
<br>> NamesGeneratorType::New();<br>> > nameGenerator->SetInputDirectory( "D:\\testimages" );<br>> ><br>> > typedef std::vector<std::string> FileNamesContainer;
<br>> > FileNamesContainer fileNames = nameGenerator->GetInputFileNames();<br>> > unsigned int numberOfFilenames = fileNames.size();<br>> > std::cout << numberOfFilenames << std::endl;
<br>> > unsigned int fni;<br>> ><br>> > for(fni = 0; fni<numberOfFilenames; fni++)<br>> > {<br>> > std::cout << "filename # " << fni << " = ";
<br>> > std::cout << fileNames[fni] << std::endl;<br>> > }<br>> ><br>> > for(fni = 0; fni<numberOfFilenames; fni++)<br>> > {<br>> > reader->SetFileName( fname);
<br>> ><br>> > reader->SetImageIO( gdcmImageIO );<br>> ><br>> > try<br>> > {<br>> > reader->Update();//this is where it gives me an error second
<br>> > time in the loop.<br>> > }<br>> > catch (itk::ExceptionObject & e)<br>> > {<br>> > std::cerr << "exception in file reader " << std::endl;
<br>> > std::cerr << e << std::endl;<br>> > return EXIT_FAILURE;<br>> > }<br>> > // code for processing the image //<br>> > //code for writing the processed image//
<br>> > }// for loop complete<br>> > --------------------------------------<br>> > The filenames are correctly read, the code runs fine the first time<br>> > through the for loop, but second time it gives an error at the
<br>> > reader->Update() line.<br>> > Can anyone please tell me why is this happening and how to fix it?<br>> ><br>> > Thanks,<br>> > Ashish<br>> ><br>> >
<br>> ><br>> ------------------------------------------------------------------------<br>><br>> ><br>> > _______________________________________________<br>> > Insight-users mailing list
<br>> > <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a> <mailto:<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a>><br>> > <a href="http://www.itk.org/mailman/listinfo/insight-users">
http://www.itk.org/mailman/listinfo/insight-users</a><br>> ><br>><br>><br><br></blockquote></div><br>