denisecailab / minian

miniscope analysis pipeline with interactive visualizations
GNU General Public License v3.0
90 stars 33 forks source link

Cannot visualize several different values for sparse penalty parameter during spatial updates steps #271

Open cfiel opened 1 month ago

cfiel commented 1 month ago

Hi all,

I am trying to get minian up and running on my data but I'm having an issue visualizing the spatial footprints for different sparse penalty parameters. For some reason, I am only able to visualize a couple different values for sparse penalty at a time (as an example: 0.005 and 0.01). When I manually enter other numbers into the cell (either within the range i.e., 0.007 or outside the range, i.e., 0.02) it won't give me any errors but it just won't actually display these values in the interactive viewer. This is an issue because the parameters that I'm able to view are not the correct values for my dataset.

Let me know if any part of this is confusing and I can provide clarity or screenshots. Thank you!

austinbaggetta commented 1 month ago

Hi!

Can you provide the code block you are using to add sparseness penalty parameters to the visualization? For the first spatial update, I use the following list:

if interactive:
    sprs_ls = [5e-07, 5e-06, 5e-05, 5e-04, 5e-03, 5e-02] ## this is the list of potential values
    A_dict = dict()
    C_dict = dict()
    for cur_sprs in sprs_ls:
        cur_A, cur_mask, cur_norm = update_spatial(
            Y=Y_hw_chk,
            A=A_sub,
            b=b,
            C=C_sub,
            f=f,
            sn=sn_spatial,
            in_memory=False,
            update_background=False,
            dl_wnd=param_first_spatial["dl_wnd"],
            sparse_penal=cur_sprs,
        )
        if cur_A.sizes["unit_id"]:
            A_dict[cur_sprs] = cur_A.compute()
            C_dict[cur_sprs] = C_sub.sel(unit_id=cur_mask).compute()
    hv_res = visualize_spatial_update(A_dict, C_dict, kdims=["sparse penalty"])
cfiel commented 1 month ago

My code is exactly the same, but I think I sort of figured out what might be happening. I think it has to do with my data rather than the code itself. The output of this cell is the following:

estimating penalty parameter computing subsetting matrix fitting spatial matrix 3 out of 10 units dropped estimating penalty parameter computing subsetting matrix fitting spatial matrix 8 out of 10 units dropped estimating penalty parameter computing subsetting matrix fitting spatial matrix 10 out of 10 units dropped estimating penalty parameter computing subsetting matrix fitting spatial matrix 10 out of 10 units dropped CPU times: total: 7.55 s Wall time: 11.8 s

I think that if all the units get dropped at a particular sprse_ls, it just won't let you view it in the interactive plots. In my case, the code works fine on the demo data but then on my own data it won't let me visualize all of the sprs_ls values I specify. So I just need to figure out why the statistics of my data don't mesh well with the analysis pipeline.