<div dir="ltr">Mark,<div><br></div><div style>The patch works well. Thank for the fast response.</div><div style><br></div><div style>Joe</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 29, 2013 at 2:43 PM, Mark Hiner <span dir="ltr"><<a href="mailto:hiner@wisc.edu" target="_blank">hiner@wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Joe,<br><br> Is this resolved with the changes you and Cory made?<br><br></div> I updated the <a href="http://review.source.kitware.com/#/c/11375/" target="_blank">latest gerrit changeset</a> to include your updated scifio-imageio.<br>
<br></div>Thank you for the help on this issue!<br><br></div>- Mark<br></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Tue, May 28, 2013 at 2:40 PM, Joe Ping-Lin Hsiao <span dir="ltr"><<a href="mailto:phsiao@cs.unc.edu" target="_blank">phsiao@cs.unc.edu</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">I have a test program modified from an example I found online. It reads a 4-d image and extract the z-stack from each time step and save it as a .ome.tiff.<div>
<br></div><div>The program works fine on Mac, but on Windows it hangs at <span style="white-space:pre-wrap">itksysProcess_WaitForData() in itkSCIFIOImageIO.cxx.</span></div>
<div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">I use the SCIFIO from ITK by enabling fetch_SCIFIO.</span></div><div><span style="white-space:pre-wrap"><br>
</span></div><div><span style="white-space:pre-wrap">Here is the the code:</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><font color="#000000"><span style="white-space:pre-wrap">#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include <iostream>
#include <fstream>
#include "itkSCIFIOImageIO.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
#include "itkRGBPixel.h"
#include "itkMetaDataObject.h"
#include "itkExtractImageFilter.h"
#include <itkImageIORegion.h>
#if defined(ITK_USE_MODULAR_BUILD)
#define SPECIFIC_IMAGEIO_MODULE_TEST
#endif
int main( int argc, char * argv [] )
{
if( argc < 2)
{
std::cerr << "Usage: " << argv[0] << " input";
return EXIT_FAILURE;
}
typedef unsigned short PixelType;
const unsigned int Dimension = 4;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageIORegion ImageIORegionType;
typedef itk::ImageFileWriter<ImageType> WriterType;
typedef itk::ExtractImageFilter<ImageType, ImageType> ExtractImageFilter;
// This ImageIO won't actually be used, it's just a reference to remember how many
// T-slices there are, as the extracted ImageIO will be truncated.
itk::SCIFIOImageIO::Pointer io = itk::SCIFIOImageIO::New();
io->DebugOn();
std::string inputFilename = argv[1];
std::cout << argv[1] << std::endl;
std::cout << "before setfilename" << std::endl;
io->SetFileName(argv[1]);
std::cout << "after setfilename" << std::endl;
io->ReadImageInformation();
std::cout << "after readImageInformation" << std::endl;
unsigned int numberOfDim = io->GetNumberOfDimensions();
// Similarly this region will be reused to ensure when we know how big the image is when
// we try to extract a single T-slice
ImageIORegionType region(4);
for( unsigned long i = 0; i < numberOfDim; i++ )
{
std::cout << "Setting index: " << i << " to: " << io->GetDimensions(i) << std::endl;
region.SetIndex( i, 0 );
region.SetSize( i, io->GetDimensions(i) );
}
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->UseStreamingOn();
WriterType::Pointer writer = WriterType::New();
for( unsigned int i = 0; i < region.GetSize( numberOfDim-1 ); i++ )
{
std::cout << i << std::endl;
// When I was persisting these objects between iterations I ran into
// I ran into errors based on remembering the wrong region sizes
itk::SCIFIOImageIO::Pointer imageIO = itk::SCIFIOImageIO::New();
ExtractImageFilter::Pointer extractor = ExtractImageFilter::New();
imageIO->DebugOn();
imageIO->SetFileName(argv[1]);
imageIO->SetUseStreamedReading(true);
imageIO->SetUseStreamedWriting(true);
// reset to the largest possible region, so that the extraction region is contained
imageIO->SetIORegion( region );
imageIO->ReadImageInformation();
reader->SetImageIO(imageIO);
std::cout << "ImageIO Region: " << imageIO << std::endl;
ImageType::IndexType start;
ImageType::SizeType size;
for( unsigned int j = 0; j < numberOfDim; j++ )
{
start[j] = 0;
size[j] = io->GetDimensions(j);
}
start[ numberOfDim-1 ] = i;
//size[ numberOfDim-2 ] = 1;
size[ numberOfDim-1 ] = 1;
ImageType::RegionType desiredRegion;
desiredRegion.SetSize(size);
desiredRegion.SetIndex(start);
extractor->SetExtractionRegion(desiredRegion);
std::cout << "Region of extraction: " << extractor->GetExtractionRegion() << std::endl;
std::cout << "Largest possible reader region, pre-update: " << reader->GetImageIO()->GetIORegion() << std::endl;
extractor->SetInput(reader->GetOutput());
extractor->Update();
std::cout << "Largest possible reader region, post-update: " << reader->GetImageIO()->GetIORegion() << std::endl;
std::ostringstream istream;
istream << i << ".ome.tiff";
std::string fname = istream.str();
writer->SetFileName( fname.c_str() );
writer->SetImageIO(imageIO);
writer->SetInput(extractor->GetOutput());
try
{
writer->Update();
}
catch (itk::ExceptionObject &e)
{
std::cerr << e << std::endl;
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}</span></font><br></div><div><font color="#000000"><span style="white-space:pre-wrap"><br></span></font></div><div><font color="#000000"><span style="white-space:pre-wrap">Best,</span></font></div><div>
<font color="#000000"><span style="white-space:pre-wrap">Joe</span></font></div></div>
<br></div></div>_______________________________________________<br>
ome-users mailing list<br>
<a href="mailto:ome-users@lists.openmicroscopy.org.uk" target="_blank">ome-users@lists.openmicroscopy.org.uk</a><br>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users" target="_blank">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>