def test_1_Read(self):
        graph = Graph()
        op = OpRESTfulBlockwiseFilesetReader(graph=graph)
        op.DescriptionFilePath.setValue( self.descriptionFilePath )

        logger.debug("test_1_Read(): Reading data")        
        slice1 = numpy.s_[ 0:21, 5:27, 10:33 ]
        readData = op.Output[ slice1 ].wait()
        assert readData.shape == (21, 22, 23)
        op.cleanUp()
    def test_1_Read(self):
        graph = Graph()
        op = OpRESTfulBlockwiseFilesetReader(graph=graph)
        op.DescriptionFilePath.setValue(self.descriptionFilePath)

        logger.debug("test_1_Read(): Reading data")
        slice1 = numpy.s_[0:21, 5:27, 10:33]
        readData = op.Output[slice1].wait()
        assert readData.shape == (21, 22, 23)
        op.cleanUp()
Example #3
0
    def _attemptOpenAsRESTfulBlockwiseFileset(self, filePath):
        fileExtension = os.path.splitext(filePath)[1].lower()
        fileExtension = fileExtension.lstrip(".")  # Remove leading dot

        if fileExtension in OpInputDataReader.blockwiseExts:
            opReader = OpRESTfulBlockwiseFilesetReader(parent=self)
            try:
                # This will raise a SchemaError if this is the wrong type of json config.
                opReader.DescriptionFilePath.setValue(filePath)
                return (opReader, opReader.Output)
            except JsonConfigSchema.SchemaError:
                opReader.cleanUp()
        return (None, None)
    def test_2_ReadTranslated(self):
        # Start by reading some data
        graph = Graph()
        op = OpRESTfulBlockwiseFilesetReader(graph=graph)
        try:
            op.DescriptionFilePath.setValue(self.descriptionFilePath)

            logger.debug("test_2_Read(): Reading data")
            slice1 = numpy.s_[20:30, 30:40, 20:30]
            readData = op.Output[slice1].wait()
            assert readData.shape == (10, 10, 10)

            logger.debug("test_2_Read(): Creating translated description")
            # Create a copy of the original description, but specify a translated (and smaller) view
            desc = RESTfulBlockwiseFileset.readDescription(
                self.descriptionFilePath)
            desc.view_origin = [20, 30, 20]
            offsetConfigPath = self.descriptionFilePath + "_offset"
            RESTfulBlockwiseFileset.writeDescription(offsetConfigPath, desc)

            # Read the same data as before using the translated view (offset our roi)
            opTranslated = OpRESTfulBlockwiseFilesetReader(graph=graph)
            try:
                opTranslated.DescriptionFilePath.setValue(offsetConfigPath)

                logger.debug("test_2_Read(): Reading translated data")
                sliceTranslated = numpy.s_[0:10, 0:10, 0:10]
                translatedReadData = op.Output[sliceTranslated].wait()
                assert translatedReadData.shape == (10, 10, 10)
                assert (translatedReadData == readData
                        ).all(), "Data doesn't match!"
            finally:
                opTranslated.cleanUp()
        finally:
            op.cleanUp()
Example #5
0
    def _attemptOpenAsRESTfulBlockwiseFileset(self, filePath):
        fileExtension = os.path.splitext(filePath)[1].lower()
        fileExtension = fileExtension.lstrip('.')  # Remove leading dot

        if fileExtension in OpInputDataReader.blockwiseExts:
            opReader = OpRESTfulBlockwiseFilesetReader(parent=self)
            try:
                # This will raise a SchemaError if this is the wrong type of json config.
                opReader.DescriptionFilePath.setValue(filePath)
                return ([opReader], opReader.Output)
            except JsonConfigParser.SchemaError:
                opReader.cleanUp()
            except OpRESTfulBlockwiseFilesetReader.MissingDatasetError as e:
                raise OpInputDataReader.DatasetReadError(*e.args)
        return ([], None)
    def test_2_ReadTranslated(self):
        # Start by reading some data
        graph = Graph()
        op = OpRESTfulBlockwiseFilesetReader(graph=graph)
        op.DescriptionFilePath.setValue( self.descriptionFilePath )
        
        logger.debug("test_2_Read(): Reading data")
        slice1 = numpy.s_[ 20:30, 30:40, 20:30 ]
        readData = op.Output[ slice1 ].wait()
        assert readData.shape == (10, 10, 10)

        logger.debug("test_2_Read(): Creating translated description")
        # Create a copy of the original description, but specify a translated (and smaller) view
        desc = RESTfulBlockwiseFileset.readDescription(self.descriptionFilePath)
        desc.view_origin = [20, 30, 20]
        offsetConfigPath = self.descriptionFilePath + '_offset'
        RESTfulBlockwiseFileset.writeDescription(offsetConfigPath, desc)

        # Read the same data as before using the translated view (offset our roi)
        opTranslated = OpRESTfulBlockwiseFilesetReader(graph=graph)
        opTranslated.DescriptionFilePath.setValue( offsetConfigPath )
        
        logger.debug("test_2_Read(): Reading translated data")        
        sliceTranslated = numpy.s_[ 0:10, 0:10, 0:10 ]
        translatedReadData = op.Output[ sliceTranslated ].wait()
        assert translatedReadData.shape == (10, 10, 10)
        assert (translatedReadData == readData).all(), "Data doesn't match!"
        op.cleanUp()
        opTranslated.cleanUp()