preprocessing and conversion for mesoscope data
This package contains a module and command line tool to process raw data from the two-photon random access mesoscope (2P-RAM). The raw output of the mesocope, via the ScanImage control software, is a matrix of resonant scan lines across multiple rois stored as TIF files. For the majority of applications, users will want to merge and reshape their contents into images that are appropriately merged and reshaped. This module helps you do that.
You can install using pip
pip install mesoscope
Here we'll convert the example test data included with the repository
import mesoscope as ms
data, meta = ms.load('test/resources/input')
newdata, newmeta = ms.convert(data, meta)
data.shape
>> (23, 5152, 64)
converted.shape
>> (23, 464, 576)
Given a directory with input TIF files and a metadata file as JSON, just call
mesoscope convert input/ output/
This will create a folder output
with the converted images. Type mesoscope convert -h
to see other options. Note that during image writing int16
values will be written as uint16
so any negative values will be clipped at 0.
The mesocope
package includes just two methods
Loads both data and metadata from the specified path
. The optional engine
can be used to load the data using a parallel backend. Currently supports either None
(for local compute) or a SparkContext
(for parallelization using a Spark cluster).
Converts the given data using the provided metadata. The data
should be a numpy
array or a thunder
images
object.