LernerLab / GuPPy

Guided Photometry Analysis in Python, a free and open-source FP analysis tool.
GNU General Public License v3.0
63 stars 11 forks source link

Issues computing PSTH when combining TDT and csv data? #56

Closed mayh1 closed 10 months ago

mayh1 commented 10 months ago

Hi!

First, thank you for sharing this code and making the instructions so easy to follow! Second, I'm running into some issues with the PSTH generation - specifically, I'm recording behavior sessions using the TDT system while simultaneously recording from a camera. We then go in and manually annotate the behavior and generate a csv of those timestamps (making sure to follow the same format as the example provided). I'm hoping to combine the two during the analysis - using a combination of the TDT-generated files and my behavior timestamp csv. However, I'm getting the following errors when I try to do Step 5: PSTH Computation. Could you please help?

Thank you!!

Computing PSTH, Peak and Area for each event...
Average for group :  False
Computing PSTH for event beh...
Read progress bar increment values stopped.
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 375, in storenamePsth
    psth, psth_baselineUncorrected, cols = helper_psth(z_score, event, filepath,
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 277, in helper_psth
    psth_baselineUncorrected[i,:] = arr                                            # extra
ValueError: could not broadcast input array from shape (37819,) into shape (30519,)
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 772, in <module>
    raise e
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 763, in <module>
    inputParameters = psthForEachStorename(json.loads(sys.argv[1]))
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 743, in psthForEachStorename
    p.starmap(storenamePsth, zip(repeat(filepath), storesList[1,:], repeat(inputParameters)))
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 372, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
ValueError: could not broadcast input array from shape (37819,) into shape (30519,)

Oddly, when I tried to run it again, I got a different error:

Computing PSTH for event beh...
Read progress bar increment values stopped.
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 375, in storenamePsth
    psth, psth_baselineUncorrected, cols = helper_psth(z_score, event, filepath,
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 218, in helper_psth
    increment = ((-1*nSecPrev)+nSecPost)/totalTs
ZeroDivisionError: division by zero
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 772, in <module>
    raise e
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 763, in <module>
    inputParameters = psthForEachStorename(json.loads(sys.argv[1]))
  File "/Users/mayhui/GuPPy-main/GuPPy/computePsth.py", line 743, in psthForEachStorename
    p.starmap(storenamePsth, zip(repeat(filepath), storesList[1,:], repeat(inputParameters)))
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 372, in starmap
    return self._map_async(func, iterable, starmapstar, chunksize).get()
  File "/Users/mayhui/anaconda3/envs/guppy/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
ZeroDivisionError: division by zero
venus-sherathiya commented 10 months ago

Addressed this issue in the Gitter chat room