How to use the brainrender.Utils.data_io.load_npy_from_gz function in brainrender

To help you get started, we’ve selected a few brainrender examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BrancoLab / BrainRender / brainrender / ABA / volumetric / VolumetricConnectomeAPI.py View on Github external
def _get_from_cache(self, tgt, what):
        """ tries to load objects from cached data, if they exist"""
        if not self.use_cache:
            return None

        name, cache_path, cache_exists = self._get_cache_filename(tgt, what)
        if not cache_exists:
            return None
        else:
            return load_npy_from_gz(cache_path)
github BrancoLab / BrainRender / brainrender / ABA / volumetric / VolumetricConnectomeAPI.py View on Github external
def _load_voxel_data(self):
        "Load the VoxelData array from Knox et al 2018"
        if self.voxel_array is None:
            # Get VoxelArray
            weights_file = os.path.join(
                self.mouse_connectivity_volumetric, "voxel_model", "weights"
            )
            nodes_file = os.path.join(
                self.mouse_connectivity_volumetric, "voxel_model", "nodes"
            )

            # Try to load from numpy
            if os.path.isfile(weights_file + ".npy.gz"):
                weights = load_npy_from_gz(weights_file + ".npy.gz")
                nodes = load_npy_from_gz(nodes_file + ".npy.gz")

                # Create array
                self.voxel_array = VoxelConnectivityArray(weights, nodes)

                # Get target and source masks
                self.source_mask = self.cache.get_source_mask()
                self.target_mask = self.cache.get_target_mask()
            else:
                print("Loading voxel data, might take a few minutes.")
                # load from standard cache
                (
                    self.voxel_array,
                    self.source_mask,
                    self.target_mask,
                ) = self.cache.get_voxel_connectivity_array()
github BrancoLab / BrainRender / brainrender / ABA / volumetric / VolumetricConnectomeAPI.py View on Github external
def _load_voxel_data(self):
        "Load the VoxelData array from Knox et al 2018"
        if self.voxel_array is None:
            # Get VoxelArray
            weights_file = os.path.join(
                self.mouse_connectivity_volumetric, "voxel_model", "weights"
            )
            nodes_file = os.path.join(
                self.mouse_connectivity_volumetric, "voxel_model", "nodes"
            )

            # Try to load from numpy
            if os.path.isfile(weights_file + ".npy.gz"):
                weights = load_npy_from_gz(weights_file + ".npy.gz")
                nodes = load_npy_from_gz(nodes_file + ".npy.gz")

                # Create array
                self.voxel_array = VoxelConnectivityArray(weights, nodes)

                # Get target and source masks
                self.source_mask = self.cache.get_source_mask()
                self.target_mask = self.cache.get_target_mask()
            else:
                print("Loading voxel data, might take a few minutes.")
                # load from standard cache
                (
                    self.voxel_array,
                    self.source_mask,
                    self.target_mask,
                ) = self.cache.get_voxel_connectivity_array()