schnitzer-lab / EXTRACT-public

EXTRACT is a tractable and robust automated cell extraction tool for calcium imaging, which extracts the activities of cells as time series from both one-photon and two-photon calcium imaging movies.
MIT License
62 stars 16 forks source link

Different results using CPU and GPU #9

Closed milesOIST closed 2 years ago

milesOIST commented 3 years ago

Using the example_tutorial,m file I tried using GPU=0 and GPU=1 settings. I consistently found different results between each method. Shold this not be the same, or have I misunderstood what the example-tutorial is plotting in the last few lines?

EXTRACT_GPU_vs_CPU

fatihdinc commented 3 years ago

Let me answer the two parts of the question separately. Starting with the consistency, this is expected. EXTRACT is a deterministic algorithm. Consecutive runs of the algorithm with the same inputs will give the same output, up to very tiny differences resulting from the current state of the machine running it (such as how much GPU memory is available etc.). So, it is not surprising that the rows are identical in the figure.

As for the columns, running EXTRACT on GPU vs CPU uses the same algorithm, but has a different memory management. GPU parses the movie in different chunks than CPU does. All of this is handled internally, in reality this shouldn't cause too much difference. In this case, there is also no real difference between two runs, only the cells are mapped with different identities. The tutorial script currently only outputs the cell with ID 20. As you can see, both GPU and CPU versions output a cell that perfectly match the underlying ground truth. The difference is, they are outputting different cells, as they call different cells with the ID 20. If you go through all the cells (by changing 'pick'), you could see that all cells in the movie are found and match the ground truth perfectly, but are labelled with different numbers. Hope this helps!