leiferlab / worm-functional-connectivity

3 stars 7 forks source link

Fix syntax errors in returned code snippet #5

Closed lparsons closed 1 year ago

lparsons commented 2 years ago

BUG DESCRIPTION

Problem

The code snippet currently returned has a few syntax errors.

Steps to reproduce

  1. Numbered
  2. Steps

Current behavior

import numpy as np, matplotlib.pyplot as plt, os
import wormfunconn as wfc

# Get atlas folder
folder = os.path.join(os.path.dirname(__file__),"../atlas/")

# Create FunctionalAtlas instance from file
funatlas = wfc.FunctionalAtlas.from_file(folder,"mock")

# Set time-axis properties
nt = 1000
t_max = 100.0
dt = t_max / nt

stim = funatlas.get_standard_stimulus(nt,dt=dt,stim_type="realistic",tau1=1.0,tau2=1.2)

stim_neu_id = "AVAL"
resp_neu_ids = ['ASEL', 'AVAL', 'AVAR', 'AWAL']
top_n = None
threshold = 0.0
sort_by_amplitude = True
resp, labels, msg = funatlas.get_responses(stim, dt, stim_neu_id, resp_neu_ids=resp_neu_ids, top_n=top_n, threshold=threshold, sort_by_amplitude=sort_by_amplitude)

print(msg)

time = np.arange(nt)*dt
for i in np.arange(resp.shape[0]):
plt.plot(time,resp[i],label=labels[i],,alpha=confidences[i])
plt.legend()
plt.show()

Expected behavior

import numpy as np, matplotlib.pyplot as plt, os
import wormfunconn as wfc

# Get atlas folder
folder = os.path.join(os.path.dirname(__file__),"../atlas/")

# Create FunctionalAtlas instance from file
funatlas = wfc.FunctionalAtlas.from_file(folder,"mock")

strain = funatlas.get_strain()

# Set time-axis properties
nt = 1000
t_max = 100.0
dt = t_max / nt

stim = funatlas.get_standard_stimulus(nt,dt=dt,stim_type="realistic",tau1=1.0,tau2=1.2)

stim_neu_id = "AVAL"
resp_neu_ids = ['ASEL', 'AVAL', 'AVAR', 'AWAL']
top_n = None
threshold = 0.0
sort_by_amplitude = True
resp, labels, confidences, msg = funatlas.get_responses(stim, dt, stim_neu_id, resp_neu_ids=resp_neu_ids, top_n=top_n, threshold=threshold, sort_by_amplitude=sort_by_amplitude)

print(msg)

time = np.arange(nt)*dt
for i in np.arange(resp.shape[0]):
plt.plot(time,resp[i],label=labels[i],alpha=confidences[i])
plt.legend()
plt.show()

Suggested Change

See this gist for specific diff: https://gist.github.com/lparsons/75ca31b7c011d611126e606985c89fb2/revisions#diff-9bdd6fe19c8a772db636346fed9d3956dc97a0c8fde265c3e76ef90fe2e9a1c5

Comment

Any other relevant context or links to what you were working on when you discovered the problem.

lparsons commented 2 years ago

@fkang-pu Could you please update the "Steps to reproduce", "Current behavior" and "Expected behavior" sections of this issue? If for some reason you don't have access, just send me the details and I'll update the issue. Thanks!