Schroeder-Lab / Data

For pre-processing raw data (two-photon, ephys, bonsai, ...) and loading/saving data.
0 stars 3 forks source link

Registering Z stack with two channels #49

Closed mariacozan closed 1 year ago

mariacozan commented 1 year ago

When trying to preprocess the data with two channels, an error appears in register_zstack in preprocess_tiff: ValueError: too many values to unpack (expected 2) After debugging, indeed this is because the Z stack has an additional dimension to it. image This means that when the different resolutions are determined, the wrong axis is taken:

# Loads Z stack.
    image = skimage.io.imread(tiff_path)

# Gets the number of planes and no. of pixels along X and Y.
    planes = image.shape[0]
    resolutionx = image.shape[2]
    resolutiony = image.shape[3]

Therefore this will probably have to be dealt with separately (with a simple if loop potentially?):

if len(image.shape) > 4:
    planes = image.shape[0]
    resolutionx = image.shape[3]
    resolutiony = image.shape[4]
mariacozan commented 1 year ago

One more thing that needs to be changed is when calling this function:

res = register_frames(
            image[i, 0, 0, :, :], image[i, :, 0, :, :].astype(np.int16)
        )

previously this was:

res = register_frames(
            image[i, 0, :, :], image[i, :, :, :].astype(np.int16)
        )
liadJB commented 1 year ago

Fixed the bug. Now checks for the number of dimensions right at the start and accepts a new parameter that is the channel the processing is aligned by. Then the image itself is made into the right number of dimensions at the outsets precluding any need for further changes.