abcucberkeley / PetaKit5D

Other
21 stars 7 forks source link

Option flag for DSR with vertical scan direction #1

Closed conorhughmcfadden closed 5 days ago

conorhughmcfadden commented 2 weeks ago

Hello,

I'm a grad student at UT Southwestern in Reto Fiolka's lab. We are really enjoying PetaKit5D and are starting to use it more and more for shearing our OPM data!

The issue is that our OPMs produce stacks which are sheared in the vertical direction, but as far as I can tell deskewing in PetaKit5D assumes a horizontal scan direction in the images. As such, we are having to manually load the stacks, transpose them and resave them before using, and then passing that path to XR_deskew_rotate_data_wrapper . This of course doubles our data storage and has a significant time cost.

Is there a flag in XR_deskew_rotate_data_wrapper to specify a vertical DSR direction? If not, could you add a flag 'transpose' or something similar, which simply permutes the x,y directions before applying DSR? Or maybe just performs the actual DSR in the orthogonal direction?

For reference, here is the function I am running on our data before passing to XR_deskew_rotate_data_wrapper:

function [ newDataPath ] = rotate_all_stacks(dataPath)
    clear dir dirs;
    stackList = dir(fullfile(dataPath, "*.tif"));

    newDataPath = fullfile(dataPath, 'rotated');
    if ~exist(newDataPath, 'dir')
        mkdir(newDataPath);
    else
        return;
    end

    for i = 1:length(stackList)
        readPath = fullfile(stackList(i).folder, stackList(i).name);
        fprintf("Rotating %s...\n", readPath);

        stack = readtiff(readPath);
        stack = permute(stack, [2,1,3]);

        writePath = fullfile(newDataPath, stackList(i).name);
        writetiff(stack, writePath);
    end
end

If I'm missing some obvious parameter that already exists, please let me know. Thank you!

conorhughmcfadden commented 2 weeks ago

I think you guys may have already talked to Reto. Sorry for doubling up!

ruanxt commented 5 days ago

We have added support for other input/output data axis orders for the deskew/rotation function. Please check out the latest version: https://github.com/abcucberkeley/PetaKit5D/commit/1183bb35f6a21c12c207111ab73d90860c4c8b6f.