nel-lab / mesmerize-core

High level pandas-based API for batch analysis of Calcium Imaging data using CaImAn
Other
59 stars 15 forks source link

ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 140 and the array at index 1 has size 141 #253

Closed qweasdf1354 closed 8 months ago

qweasdf1354 commented 10 months ago

Hi, author! after run the mcorr and cnmf, I use the following code but occur some unexpected. is that something i set wrong? I use windows10 system. and I update the viz by git. and restart the kernel but not help. Could you help me?

iw_rcm = fpl.ImageWidget(
    data=[input_movie, rcm, rcb, residuals], 
    grid_plot_kwargs={"size": (800, 600)}, 
    cmap="gnuplot2"
)
iw_rcm.show()

and

viz_cnmf = df.cnmf.viz()
viz_cnmf.show()

It occur error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[34], line 1
----> 1 iw_rcm = fpl.ImageWidget(
      2     data=[input_movie, rcm, rcb, residuals], 
      3     grid_plot_kwargs={"size": (800, 600)}, 
      4     cmap="gnuplot2"
      5 )
      6 iw_rcm.show()

File ~\miniforge3\envs\mescore\lib\site-packages\fastplotlib\widgets\image.py:564, in ImageWidget.__init__(self, data, dims_order, slider_dims, window_funcs, frame_apply, grid_shape, names, grid_plot_kwargs, histogram_widget, **kwargs)
    561 subplot.set_title(name)
    563 if histogram_widget:
--> 564     hlut = HistogramLUT(
    565         data=d,
    566         image_graphic=ig,
    567         name="histogram_lut"
    568     )
    570     subplot.docks["right"].add_graphic(hlut)
    571     subplot.docks["right"].size = 80

File ~\miniforge3\envs\mescore\lib\site-packages\fastplotlib\widgets\histogram_lut.py:46, in HistogramLUT.__init__(self, data, image_graphic, nbins, flank_divisor, **kwargs)
     42 self._scale_factor: float = 1.0
     44 hist, edges, hist_scaled, edges_flanked = self._calculate_histogram(data)
---> 46 line_data = np.column_stack([hist_scaled, edges_flanked])
     48 self.line = LineGraphic(line_data)
     50 bounds = (edges[0], edges[-1])

File ~\miniforge3\envs\mescore\lib\site-packages\numpy\lib\shape_base.py:652, in column_stack(tup)
    650         arr = array(arr, copy=False, subok=True, ndmin=2).T
    651     arrays.append(arr)
--> 652 return _nx.concatenate(arrays, 1)

ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 140 and the array at index 1 has size 141

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[35], line 1
----> 1 viz_cnmf = df.cnmf.viz()
      2 viz_cnmf.show()

File c:\software\mesmerize-viz\mesmerize_viz\_cnmf.py:1194, in CNMFDataFrameVizExtension.viz(self, start_index, temporal_data_option, image_data_options, temporal_kwargs, reset_timepoint_on_change, input_movie_kwargs, image_widget_kwargs, data_grid_kwargs)
   1118 def viz(
   1119     self,
   1120     start_index: int = None,
   (...)
   1127     data_grid_kwargs: dict = None,
   1128 ):
   1129     """
   1130     Visualize CNMF output and other data columns such as behavior video (optional).
   1131 
   (...)
   1191         Example: `image_widget_kwargs={"cmap": "viridis"}`
   1192     """
-> 1194     container = CNMFVizContainer(
   1195         dataframe=self._dataframe,
   1196         start_index=start_index,
   1197         temporal_data_option=temporal_data_option,
   1198         image_data_options=image_data_options,
   1199         temporal_kwargs=temporal_kwargs,
   1200         reset_timepoint_on_change=reset_timepoint_on_change,
   1201         input_movie_kwargs=input_movie_kwargs,
   1202         image_widget_kwargs=image_widget_kwargs,
   1203         data_grid_kwargs=data_grid_kwargs,
   1204 
   1205     )
   1207     return container

File c:\software\mesmerize-viz\mesmerize_viz\_cnmf.py:584, in CNMFVizContainer.__init__(self, dataframe, start_index, temporal_data_option, image_data_options, temporal_kwargs, reset_timepoint_on_change, input_movie_kwargs, image_widget_kwargs, data_grid_kwargs)
    581 self._cnmf_obj: CNMF = None
    583 data_arrays = self._get_row_data(index=start_index)
--> 584 self._set_data(data_arrays)
    586 self._set_params_text_area(index=start_index)
    588 self._widget = None

File c:\software\mesmerize-viz\mesmerize_viz\_cnmf.py:720, in CNMFVizContainer._set_data(self, data_arrays)
    717 self._synchronizer.add(self._linear_selector_heatmap)
    719 if self._image_widget is None:
--> 720     self._image_widget = fpl.ImageWidget(
    721         data=data_arrays["images"],
    722         names=self._image_data_options,
    723         **self.image_widget_kwargs
    724     )
    726     self._image_widget.gridplot.renderer.add_event_handler(self._manual_toggle_component, "key_down")
    728     # need to start it here so that we can access the toolbar to link events with the slider

File ~\miniforge3\envs\mescore\lib\site-packages\fastplotlib\widgets\image.py:564, in ImageWidget.__init__(self, data, dims_order, slider_dims, window_funcs, frame_apply, grid_shape, names, grid_plot_kwargs, histogram_widget, **kwargs)
    561 subplot.set_title(name)
    563 if histogram_widget:
--> 564     hlut = HistogramLUT(
    565         data=d,
    566         image_graphic=ig,
    567         name="histogram_lut"
    568     )
    570     subplot.docks["right"].add_graphic(hlut)
    571     subplot.docks["right"].size = 80

File ~\miniforge3\envs\mescore\lib\site-packages\fastplotlib\widgets\histogram_lut.py:46, in HistogramLUT.__init__(self, data, image_graphic, nbins, flank_divisor, **kwargs)
     42 self._scale_factor: float = 1.0
     44 hist, edges, hist_scaled, edges_flanked = self._calculate_histogram(data)
---> 46 line_data = np.column_stack([hist_scaled, edges_flanked])
     48 self.line = LineGraphic(line_data)
     50 bounds = (edges[0], edges[-1])

File ~\miniforge3\envs\mescore\lib\site-packages\numpy\lib\shape_base.py:652, in column_stack(tup)
    650         arr = array(arr, copy=False, subok=True, ndmin=2).T
    651     arrays.append(arr)
--> 652 return _nx.concatenate(arrays, 1)

ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 140 and the array at index 1 has size 141
kushalkolar commented 9 months ago

Yes! i can run the notebook in ubuntu 22.04 and can see the tiff using the viz and can record a video. I wanna to know is that possible that I run the viz to see the behaviour video and neural activity tiff and some extracted neural activity trace simutanously, which i wanna to make a typical video for presentation or publication. Thanks a lot for your help!

You will need to use fastplotlib and pynapple directly. I would recommend going through the basic examples from each before attempting this. We have a demo notebook from SFN that shows how to combine both to sync calcium & behavior data: https://github.com/fastplotlib/fastplotlib-sfn2023/blob/main/neuro_demo.ipynb

And may I invite you to be author in my this project, which may be accomplish in this year. I really appreciate for your help!

I'm not sure, I would need more info/context on it etc.

qweasdf1354 commented 9 months ago

I'm not sure, I would need more info/context on it etc. Sure, we wanna to take more deeply contact, could you give me your email and let we contact in the email?

You will need to use fastplotlib and pynapple directly. I would recommend going through the basic examples from each before attempting this. We have a demo notebook from SFN that shows how to combine both to sync calcium & behavior data: https://github.com/fastplotlib/fastplotlib-sfn2023/blob/main/neuro_demo.ipynb

Thanks, I will try to learn this great tool.

qweasdf1354 commented 9 months ago

I'm not sure, I would need more info/context on it etc.

Sure, we wanna to take more deeply contact, could you give me your email and let we contact in the email?

kushalkolar commented 9 months ago

Hi, share your email when you can, I don't want to keep my email publicly visible for a long time. I'll delete your email post after copying it.

qweasdf1354 commented 9 months ago

Ok, kushal, Sorry for delay, our team will email you soon!

qweasdf1354 commented 9 months ago

Hi, Kushal, my mentor send a email, please check it

kushalkolar commented 8 months ago

closing, feel free to open a new issue if you have further questions