May-15-2023, 09:09 AM
Hi, I'm a student currently doing experimental work in a lab and need to analyse some data. The data includes sniffing data from animals and I need to plot out sniffing rate. My mentor told me to use the NumPy Histogram function to do it, but I'm running into some struggles. The assignment is the following:
# calculate for each trial how many inhalations were performed in 0,5 bins
# trials are found in single ses_ids
# look up function np histogram
# then calculate mean sniffing across time for all trials and plot it
What I have already got so far is:
What I want to do but can't is:
# how can I arrange bins to be 0,5 interval and how can I make the range fit the data?
# how can I make my path go INTO the ses_id and pick individual trials from there?
# how can I plot the histogram then? I think it's something like:
Any help is appreciated!
# calculate for each trial how many inhalations were performed in 0,5 bins
# trials are found in single ses_ids
# look up function np histogram
# then calculate mean sniffing across time for all trials and plot it
What I have already got so far is:
import matplotlib.pyplot as plt import numpy as np import os data_path = r'C:\Users\32487\OneDrive\Documenten\Internship_data_KK4748' ses_ids = ['230317_KK047', '230317_KK048'] for ses_id in ses_ids: ses_path = os.path.join(data_path, ses_id) print(ses_path) hist, bin_edges = np.histogram([ses_path], bins = range(10)) print(hist) print(bin_edges)
What I want to do but can't is:
# how can I arrange bins to be 0,5 interval and how can I make the range fit the data?
# how can I make my path go INTO the ses_id and pick individual trials from there?
# how can I plot the histogram then? I think it's something like:
plt.hist([ses_path]) plt.show()So basically with the function I have, I get the histogram [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], because I put the range at 10, and I did not make my path go into my file folder with the data (which I don't know how to do) but rather into the general named folder.
Any help is appreciated!