def test_zz_quickstart_usage(self):
        import json
        import httplib
        import numpy
        from pydvid import voxels, general
          
        # Open a connection to DVID
        connection = httplib.HTTPConnection( "localhost:8000", timeout=5.0 )
         
        # Get detailed dataset info: /api/datasets/info
        dataset_details = general.get_repos_info( connection )
        # print json.dumps( dataset_details, indent=4 )
         
        # Create a new remote volume
        uuid = 'abcde'
        voxels_metadata = voxels.VoxelsMetadata.create_default_metadata( (4,0,0,0), numpy.uint8, 'cxyz', 1.0, "" )
        voxels.create_new( connection, uuid, "my_volume", voxels_metadata )
 
        # Use the VoxelsAccessor convenience class to manipulate a particular data volume     
        dvid_volume = voxels.VoxelsAccessor( connection, uuid, "my_volume" )
        # print dvid_volume.axiskeys, dvid_volume.dtype, dvid_volume.minindex, dvid_volume.shape
          
        # Add some data
        updated_data = numpy.ones( (4,100,100,100), dtype=numpy.uint8 ) # Must include all channels.
        dvid_volume[:, 10:110, 20:120, 30:130] = updated_data
        # OR:
        dvid_volume.post_ndarray( (0,10,20,30), (4,110,120,130), updated_data )
         
        # Read from it (First axis is channel.)
        cutout_array = dvid_volume[:, 10:110, 20:120, 30:130]
        # OR:
        cutout_array = dvid_volume.get_ndarray( (0,10,20,30), (4,110,120,130) )
 
        assert isinstance(cutout_array, numpy.ndarray)
        assert cutout_array.shape == (4,100,100,100)
 def test_create_volume(self):
     """
     Create a new remote volume.  Verify that the server created it in the hdf5 file.
     """
     volume_name = 'new_volume'
     metadata = voxels.VoxelsMetadata.create_default_metadata((4,0,0,0), numpy.uint8, 'cxyz', 1.0, "")
     voxels.create_new( self.client_connection, self.data_uuid, volume_name, metadata )
      
     with h5py.File(self.test_filepath, 'r') as f:
         volumes_group = "/datasets/{dvid_dataset}/volumes".format( dvid_dataset=self.dvid_dataset )
         assert volume_name in f[volumes_group], "Volume wasn't created: {}".format( volumes_group + "/" + volume_name )
         
         metadata_from_file = voxels.VoxelsMetadata.create_from_h5_dataset( f["all_nodes"][self.data_uuid][volume_name] )
         assert metadata_from_file == metadata, "New volume has the wrong metadata"
Beispiel #3
0
    def test_create_volume(self):
        """
        Create a new remote volume.  Verify that the server created it in the hdf5 file.
        """
        volume_name = 'new_volume'
        metadata = voxels.VoxelsMetadata.create_default_metadata(
            (4, 0, 0, 0), numpy.uint8, 'cxyz', 1.0, "")
        voxels.create_new(self.client_connection, self.data_uuid, volume_name,
                          metadata)

        with h5py.File(self.test_filepath, 'r') as f:
            volumes_group = "/datasets/{dvid_dataset}/volumes".format(
                dvid_dataset=self.dvid_dataset)
            assert volume_name in f[
                volumes_group], "Volume wasn't created: {}".format(
                    volumes_group + "/" + volume_name)

            metadata_from_file = voxels.VoxelsMetadata.create_from_h5_dataset(
                f["all_nodes"][self.data_uuid][volume_name])
            assert metadata_from_file == metadata, "New volume has the wrong metadata"
Beispiel #4
0
    def test_zz_quickstart_usage(self):
        import json
        import httplib
        import numpy
        from pydvid import voxels, general

        # Open a connection to DVID
        connection = httplib.HTTPConnection("localhost:8000", timeout=5.0)

        # Get detailed dataset info: /api/datasets/info
        dataset_details = general.get_repos_info(connection)
        # print json.dumps( dataset_details, indent=4 )

        # Create a new remote volume
        uuid = 'abcde'
        voxels_metadata = voxels.VoxelsMetadata.create_default_metadata(
            (4, 0, 0, 0), numpy.uint8, 'cxyz', 1.0, "")
        voxels.create_new(connection, uuid, "my_volume", voxels_metadata)

        # Use the VoxelsAccessor convenience class to manipulate a particular data volume
        dvid_volume = voxels.VoxelsAccessor(connection, uuid, "my_volume")
        # print dvid_volume.axiskeys, dvid_volume.dtype, dvid_volume.minindex, dvid_volume.shape

        # Add some data
        updated_data = numpy.ones(
            (4, 100, 100, 100),
            dtype=numpy.uint8)  # Must include all channels.
        dvid_volume[:, 10:110, 20:120, 30:130] = updated_data
        # OR:
        dvid_volume.post_ndarray((0, 10, 20, 30), (4, 110, 120, 130),
                                 updated_data)

        # Read from it (First axis is channel.)
        cutout_array = dvid_volume[:, 10:110, 20:120, 30:130]
        # OR:
        cutout_array = dvid_volume.get_ndarray((0, 10, 20, 30),
                                               (4, 110, 120, 130))

        assert isinstance(cutout_array, numpy.ndarray)
        assert cutout_array.shape == (4, 100, 100, 100)