예제 #1
0
    def launch(self, data_file):
        if data_file is None:
            raise LaunchException(
                "Please select ZIP file which contains data to import")

        #todo warn: all in memory, this is memory hungry; at least twice the tractografy

        tracts = []
        max_tract_count = 0

        with TvbZip(data_file) as zipf:
            # todo sort tract8 before tract74 parse ints out of file names
            for tractf in zipf.namelist():
                vertices_file = zipf.open(tractf)
                tract_vertices = numpy.loadtxt(vertices_file,
                                               dtype=numpy.float32)
                tracts.append(tract_vertices)
                max_tract_count = max(max_tract_count, len(tract_vertices))
                vertices_file.close()

        vertices_arr = numpy.zeros((len(tracts), max_tract_count, 3))
        counts_arr = numpy.zeros((len(tracts), ))

        for i, tr in enumerate(tracts):
            vertices_arr[i, :len(tr)] = tr
            counts_arr[i] = len(tr)

        datatype = Tracts()
        datatype.storage_path = self.storage_path
        datatype.vertices = vertices_arr
        datatype.vertex_counts = counts_arr
        return datatype
예제 #2
0
    def launch(self, data_file):
        if data_file is None:
            raise LaunchException("Please select ZIP file which contains data to import")

        # todo warn: all in memory, this is memory hungry; at least twice the tractografy

        tracts = []
        max_tract_count = 0

        with TvbZip(data_file) as zipf:
            # todo sort tract8 before tract74 parse ints out of file names
            for tractf in zipf.namelist():
                vertices_file = zipf.open(tractf)
                tract_vertices = numpy.loadtxt(vertices_file, dtype=numpy.float32)
                tracts.append(tract_vertices)
                max_tract_count = max(max_tract_count, len(tract_vertices))
                vertices_file.close()

        vertices_arr = numpy.zeros((len(tracts), max_tract_count, 3))
        counts_arr = numpy.zeros((len(tracts),))

        for i, tr in enumerate(tracts):
            vertices_arr[i, : len(tr)] = tr
            counts_arr[i] = len(tr)

        datatype = Tracts()
        datatype.storage_path = self.storage_path
        datatype.vertices = vertices_arr
        datatype.vertex_counts = counts_arr
        return datatype
예제 #3
0
    def _base_before_launch(self, data_file, region_volume_gid):
        if data_file is None:
            raise LaunchException("Please select a file to import!")

        if region_volume_gid is not None:
            rvm_h5 = h5.h5_file_for_gid(region_volume_gid)
            self._attempt_to_cache_regionmap(rvm_h5)
            self.region_volume_shape = rvm_h5.read_data_shape()
            self.region_volume_h5 = rvm_h5

        datatype = Tracts()
        dummy_rvm = RegionVolumeMapping()
        dummy_rvm.gid = region_volume_gid
        datatype.region_volume_map = dummy_rvm
        return datatype
예제 #4
0
    def _base_before_launch(self, data_file, region_volume):
        if data_file is None:
            raise LaunchException("Please select a file to import")

        self.region_volume = region_volume

        if region_volume is not None:
            self._attempt_to_cache_regionmap(region_volume)
            # this is called here and not in _get_tract_region because it goes to disk to get this info
            # which would massively dominate the runtime of the import
            self.region_volume_shape = region_volume.read_data_shape()

        datatype = Tracts()
        datatype.storage_path = self.storage_path
        datatype.region_volume_map = region_volume
        return datatype
    def _base_before_launch(self, data_file, region_volume):
        if data_file is None:
            raise LaunchException("Please select a file to import")

        self.region_volume = region_volume

        if region_volume is not None:
            self._attempt_to_cache_regionmap(region_volume)
            # this is called here and not in _get_tract_region because it goes to disk to get this info
            # which would massively dominate the runtime of the import
            self.region_volume_shape = region_volume.read_data_shape()

        datatype = Tracts()
        datatype.storage_path = self.storage_path
        datatype.region_volume_map = region_volume
        return datatype