bmtool 0.7.1.3__py3-none-any.whl → 0.7.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -714,7 +714,17 @@ def calculate_spike_rate_power_correlation(
714
714
  return correlation_results, frequencies
715
715
 
716
716
 
717
- def get_spikes_in_cycle(spike_df, lfp_data, spike_fs=1000, lfp_fs=400, band=(30, 80)):
717
+ def get_spikes_in_cycle(
718
+ spike_df,
719
+ lfp_data,
720
+ spike_fs=1000,
721
+ lfp_fs=400,
722
+ filter_method="butter",
723
+ lowcut=None,
724
+ highcut=None,
725
+ bandwidth=2.0,
726
+ freq_of_interest=None,
727
+ ):
718
728
  """
719
729
  Analyze spike timing relative to oscillation phases.
720
730
 
@@ -733,12 +743,15 @@ def get_spikes_in_cycle(spike_df, lfp_data, spike_fs=1000, lfp_fs=400, band=(30,
733
743
  phase_data : dict
734
744
  Dictionary containing phase values for each spike and neuron population
735
745
  """
736
- filtered_lfp = butter_bandpass_filter(lfp_data, band[0], band[1], lfp_fs)
737
-
738
- # Calculate phase using Hilbert transform
739
- analytic_signal = signal.hilbert(filtered_lfp)
740
- phase = np.angle(analytic_signal)
741
- amplitude = np.abs(analytic_signal)
746
+ phase = get_lfp_phase(
747
+ lfp_data=lfp_data,
748
+ fs=lfp_fs,
749
+ filter_method=filter_method,
750
+ lowcut=lowcut,
751
+ highcut=highcut,
752
+ bandwidth=bandwidth,
753
+ freq_of_interest=freq_of_interest,
754
+ )
742
755
 
743
756
  # Get unique neuron populations
744
757
  neuron_pops = spike_df["pop_name"].unique()
@@ -763,4 +776,4 @@ def get_spikes_in_cycle(spike_df, lfp_data, spike_fs=1000, lfp_fs=400, band=(30,
763
776
  valid_samples = spike_indices[valid_indices]
764
777
  phase_data[pop] = phase[valid_samples]
765
778
 
766
- return phase_data, filtered_lfp, phase, amplitude
779
+ return phase_data
bmtool/analysis/spikes.py CHANGED
@@ -401,7 +401,7 @@ def compare_firing_over_times(
401
401
 
402
402
 
403
403
  def find_bursting_cells(
404
- df: pd.DataFrame, burst_threshold: float = 10, rename_bursting_cells: bool = False
404
+ df: pd.DataFrame, isi_threshold: float = 10, burst_count_threshold: int = 1
405
405
  ) -> pd.DataFrame:
406
406
  """
407
407
  Finds bursting cells in a population based on a time difference threshold.
@@ -410,10 +410,10 @@ def find_bursting_cells(
410
410
  ----------
411
411
  df : pd.DataFrame
412
412
  DataFrame containing spike data with columns for timestamps, node_ids, and pop_name
413
- burst_threshold : float, optional
413
+ isi_threshold : float, optional
414
414
  Time difference threshold in milliseconds to identify bursts
415
- rename_bursting_cells : bool, optional
416
- If True, returns a DataFrame with bursting cells renamed in their pop_name column
415
+ burst_count_threshold : int, optional
416
+ Number of bursts required to identify a bursting cell
417
417
 
418
418
  Returns
419
419
  -------
@@ -425,10 +425,11 @@ def find_bursting_cells(
425
425
  diff_df["time_diff"] = df.groupby("node_ids")["timestamps"].diff()
426
426
 
427
427
  # Create a column indicating whether each time difference is a burst
428
- diff_df["is_burst_instance"] = diff_df["time_diff"] < burst_threshold
428
+ diff_df["is_burst_instance"] = diff_df["time_diff"] < isi_threshold
429
429
 
430
430
  # Group by node_ids and check if any row has a burst instance
431
- burst_summary = diff_df.groupby("node_ids")["is_burst_instance"].any()
431
+ # check if there are enough bursts
432
+ burst_summary = diff_df.groupby("node_ids")["is_burst_instance"].sum() >= burst_count_threshold
432
433
 
433
434
  # Convert to a DataFrame with reset index
434
435
  burst_cells = burst_summary.reset_index(name="is_burst")
@@ -437,19 +438,16 @@ def find_bursting_cells(
437
438
  burst_cells = pd.merge(burst_cells, df, on="node_ids")
438
439
 
439
440
  # Create a mask for burst cells that don't already have "_bursters" in their name
440
- burst_mask = (burst_cells["is_burst"] is True) & (
441
- ~burst_cells["pop_name"].str.contains("_bursters")
441
+ burst_mask = burst_cells["is_burst"] & ~burst_cells["pop_name"].str.contains(
442
+ "_bursters", na=False
442
443
  )
443
444
 
444
445
  # Add "_bursters" suffix only to those cells
445
- if rename_bursting_cells:
446
- burst_cells.loc[burst_mask, "pop_name"] = (
447
- burst_cells.loc[burst_mask, "pop_name"] + "_bursters"
448
- )
446
+ burst_cells.loc[burst_mask, "pop_name"] = burst_cells.loc[burst_mask, "pop_name"] + "_bursters"
449
447
 
450
- for pop in burst_cells["pop_name"].unique():
448
+ for pop in sorted(burst_cells["pop_name"].unique()):
451
449
  print(
452
- f"Number of bursters in {pop}: {burst_cells[burst_cells['pop_name'] == pop]['node_ids'].nunique()}"
450
+ f"Number of cells in {pop}: {burst_cells[burst_cells['pop_name'] == pop]['node_ids'].nunique()}"
453
451
  )
454
452
 
455
453
  return burst_cells
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bmtool
3
- Version: 0.7.1.3
3
+ Version: 0.7.1.5
4
4
  Summary: BMTool
5
5
  Home-page: https://github.com/cyneuro/bmtool
6
6
  Download-URL:
@@ -8,10 +8,10 @@ bmtool/plot_commands.py,sha256=Dxm_RaT4CtHnfsltTtUopJ4KVbfhxtktEB_b7bFEXII,12716
8
8
  bmtool/singlecell.py,sha256=I2yolbAnNC8qpnRkNdnDCLidNW7CktmBuRrcowMZJ3A,45041
9
9
  bmtool/synapses.py,sha256=wlRY7IixefPzafqG6k2sPIK4s6PLG9Kct-oCaVR29wA,64269
10
10
  bmtool/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- bmtool/analysis/entrainment.py,sha256=uG2TWbeYJEg_VQB6pKEWlrVBzQ6M4h6FSAZR4GMKp-E,28178
11
+ bmtool/analysis/entrainment.py,sha256=PM4Do8Cl248Y2kIXLRFLPmUB_mH38Yhl8CUDDcunGq0,28241
12
12
  bmtool/analysis/lfp.py,sha256=S2JvxkjcK3-EH93wCrhqNSFY6cX7fOq74pz64ibHKrc,26556
13
13
  bmtool/analysis/netcon_reports.py,sha256=VnPZNKPaQA7oh1q9cIatsqQudm4cOtzNtbGPXoiDCD0,2909
14
- bmtool/analysis/spikes.py,sha256=Mz0e7XOey_6eWQDZAU0ePjDzDMDTFkMbWSA5YWDooYk,17122
14
+ bmtool/analysis/spikes.py,sha256=IHxV7_X8ojh4NDVBjzHCzfHF8muPPef2UtH3yqYre78,17091
15
15
  bmtool/bmplot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  bmtool/bmplot/connections.py,sha256=P1JBG4xCbLVq4sfQuUE6c3dO949qajrjdQcrazdmDS4,53861
17
17
  bmtool/bmplot/entrainment.py,sha256=VSlZvcSeXLr5OxGvmWcGU4s7JS7vOL38lq1XC69O_AE,6926
@@ -26,9 +26,9 @@ bmtool/util/commands.py,sha256=Nn-R-4e9g8ZhSPZvTkr38xeKRPfEMANB9Lugppj82UI,68564
26
26
  bmtool/util/util.py,sha256=owce5BEusZO_8T5x05N2_B583G26vWAy7QX29V0Pj0Y,62818
27
27
  bmtool/util/neuron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  bmtool/util/neuron/celltuner.py,sha256=lokRLUM1rsdSYBYrNbLBBo39j14mm8TBNVNRnSlhHCk,94868
29
- bmtool-0.7.1.3.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
30
- bmtool-0.7.1.3.dist-info/METADATA,sha256=GpvzWhlfyNgHHCfhakOBeeablgTAOCHeQFvhnExZ-X8,3577
31
- bmtool-0.7.1.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
32
- bmtool-0.7.1.3.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
33
- bmtool-0.7.1.3.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
34
- bmtool-0.7.1.3.dist-info/RECORD,,
29
+ bmtool-0.7.1.5.dist-info/licenses/LICENSE,sha256=qrXg2jj6kz5d0EnN11hllcQt2fcWVNumx0xNbV05nyM,1068
30
+ bmtool-0.7.1.5.dist-info/METADATA,sha256=pvpABD7P2ytzO08EYUC8HrbUTg_fk8pc67mBaEvi7-M,3577
31
+ bmtool-0.7.1.5.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
32
+ bmtool-0.7.1.5.dist-info/entry_points.txt,sha256=0-BHZ6nUnh0twWw9SXNTiRmKjDnb1VO2DfG_-oprhAc,45
33
+ bmtool-0.7.1.5.dist-info/top_level.txt,sha256=gpd2Sj-L9tWbuJEd5E8C8S8XkNm5yUE76klUYcM-eWM,7
34
+ bmtool-0.7.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5