Skip to content

Reduce memory footprint in suite2p registration by restricting the cast to float32 to single planes.  #14

@MaximilianHoffmann

Description

@MaximilianHoffmann
ef register(self,
        siffio : 'SiffIO',
        *args,
        alignment_color_channel : int = 0,
        **kwargs
        ):
        """
        Registers individual planes using suite2p's registration method.
        
        If a kwarg called `ops` is provided, that's passed to suite2p's
        registration_wrapper function. Otherwise, the default_ops are used.
        """

        try:
            from suite2p import default_ops
            from suite2p.registration import register
        except ImportError:
            raise ImportError(
                "Suite2p is not installed. Please install suite2p to use this module."
            )


        frames = siffio.get_frames(
            frames = self.im_params.flatten_by_timepoints(color_channel=alignment_color_channel),
            registration = {}, # guarantee the raw frames
        ).astype(np.float32).reshape(-1, *self.im_params.volume_one_color)

        registered_frames = np.zeros_like(frames)

Right now at the beginning memory is allocated for 2x dataset size(one color channel only) as dtype single. At least for me this blow up my machine pretty quickly.
One solution would be to cast the dataset to single only for the slice that's currently being registered.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions