-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated pixels analysis #1
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,81 @@ | |||
def significance_extraction(CI): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the functions in this module are duplicated elsewhere in one of your own scripts. What's the difference between them?
#First sort the data into long form for both datasets, by percentile | ||
CIs_long = CIs.reset_index().melt("percentile").sort_values("value", ascending= dir_ascending) | ||
CIs_long = CIs_long.reset_index() | ||
CIs_long["index"] = pd.Series(range(0, CIs_long.shape[0]))#reset the index column to allow ordered plotting | ||
|
||
CIs_long_sig = sig_CIs.reset_index().melt("percentile").sort_values("value", ascending=dir_ascending) | ||
CIs_long_sig = CIs_long_sig.reset_index() | ||
CIs_long_sig["index"] = pd.Series(range(0, CIs_long_sig.shape[0])) | ||
|
||
#Now select if we want only significant values plotted, else raise an error. | ||
if sig_only is True: | ||
data = CIs_long_sig | ||
|
||
elif sig_only is False: | ||
data = CIs_long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move the dataframe wrangling into the if statement? That way CIs_long_sig
won't need to be generated when sig_only is False
and vice versa
noise_tests = Experiment( | ||
["noisetest1"], | ||
NoBehaviour, | ||
"~/duguidlab/visuomotor_control/neuropixels", | ||
) | ||
|
||
noise_test_unchanged = Experiment( | ||
["noisetest_unchanged"], | ||
NoBehaviour, | ||
"~/duguidlab/visuomotor_control/neuropixels", | ||
) | ||
|
||
noise_test_nopi = Experiment( | ||
["noisetest_nopi"], | ||
NoBehaviour, | ||
"~/duguidlab/visuomotor_control/neuropixels", | ||
) | ||
|
||
noise_test_no_caps = Experiment( | ||
"VR50", | ||
Reach, | ||
"~/duguidlab/visuomotor_control/neuropixels", | ||
) | ||
|
||
# This contains the list of experiments we want to plot noise for, here only interested in the reaching task | ||
# Remember to change this in base.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pixtools
should be general functions that anyone could use - this code here is not general, it's using specific experiments for something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise the sys.path
stuff at the top, which is incidental to your setup
to local space to stop spamming the repo
…rst phase of dissertation work
|
||
|
||
#Now determine the optimal number of clusters to use in the K-means analysis by producing elbow plots | ||
def elbowplot(data, myexp): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this function twice?
from pixels import Experiment | ||
from pixels.behaviours.leverpush import LeverPush | ||
from pixels.behaviours.pushpull import PushPull | ||
from pixels.behaviours.reach import Reach | ||
from pixels.behaviours.no_behaviour import NoBehaviour | ||
|
||
import numpy as np | ||
import pandas as pd | ||
import seaborn as sns | ||
import datetime | ||
import matplotlib.pyplot as plt | ||
|
||
from pixtools import clusters | ||
from pixtools import utils | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove imports that are not needed in this file? None of those behaviour classes are needed
@@ -0,0 +1,148 @@ | |||
# Unlike other noiseplot file (by channel) this file will cluster the SDs, allowing for a mean square analysis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you move this module into a new folder pixtools/noise/
rather than pixtools/clusters/
? 'clusters' here refers to clusters of spikes as determined by kilosort, not clustering analyses.
random_state=42, # The random number seed for centroid generation, can really be anything for our purposes | ||
) | ||
|
||
df2 = data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this variable is redundant, why not just use data
for the rest of the function?
plt.ylabel("Channel Noise (SD)") | ||
plt.title(f"{name} Channel Noise k-Mean Clustering Analysis") | ||
|
||
plt.show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice if users of this module aren't locked into using plt.show()
and accessing generated plots exclusively via opened windows. Perhaps we could just pass a single session into this function, make the plot, then return the axis used that contains the plot? Then client code can create a figure/axis, or alternatively make a bunch of subplots (i.e. per sesssion) then do this inner loop themselves if that's how they wanted to plot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for the elbow plot function above
from turtle import fd | ||
from channeldepth import * | ||
from channeldepth import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you remove this turtle
import? It isn't used in this module, and in any case isn't a dependency of pixels so it would be good to keep those limited to what is already needed.
Also what is channeldepth here? I dont see the module
… files containing fano factor analyses
Have updated my fork to include analysis scripts and figures. Changes confined to my projects folder with the exception of a k-means clustering script added to pixtools/clusters/.