Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

Aidan-MT
Copy link

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/.

@@ -0,0 +1,81 @@
def significance_extraction(CI):
Copy link
Member

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?

Comment on lines 48 to 62
#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
Copy link
Member

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

Comment on lines 39 to 64
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
Copy link
Member

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

Copy link
Member

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



#Now determine the optimal number of clusters to use in the K-means analysis by producing elbow plots
def elbowplot(data, myexp):
Copy link
Member

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?

Comment on lines 13 to 27
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

Copy link
Member

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
Copy link
Member

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
Copy link
Member

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()
Copy link
Member

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.

Copy link
Member

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

Comment on lines 8 to 10
from turtle import fd
from channeldepth import *
from channeldepth import *
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants