diff --git a/loren_frank_data_processing/multiunit.py b/loren_frank_data_processing/multiunit.py index f88e0f3..e37dbe8 100644 --- a/loren_frank_data_processing/multiunit.py +++ b/loren_frank_data_processing/multiunit.py @@ -86,7 +86,7 @@ def get_multiunit_dataframe2(tetrode_key, animals): time = pd.TimedeltaIndex( multiunit_data["times"][0, 0].squeeze(), unit="s", name="time" ) - multiunit = multiunit_data["marks"][0, 0].astype(np.float) + multiunit = multiunit_data["marks"][0, 0].astype(float) column_names = [ "channel_{number}_max".format(number=number + 1) for number in np.arange(multiunit.shape[1]) diff --git a/loren_frank_data_processing/neurons.py b/loren_frank_data_processing/neurons.py index d641138..8cfc1f8 100644 --- a/loren_frank_data_processing/neurons.py +++ b/loren_frank_data_processing/neurons.py @@ -164,7 +164,7 @@ def get_all_spike_indicators(neuron_keys, animals, time_function=get_trial_time) ) ) except IndexError: - bin_counts.append(np.zeros_like(time, dtype=np.float64)) + bin_counts.append(np.zeros_like(time, dtype=float)) return pd.DataFrame(np.stack(bin_counts, axis=1), columns=neuron_names, index=time) diff --git a/loren_frank_data_processing/position.py b/loren_frank_data_processing/position.py index 0c47a79..013615f 100644 --- a/loren_frank_data_processing/position.py +++ b/loren_frank_data_processing/position.py @@ -169,7 +169,6 @@ def _get_linpos_dataframe( def calculate_linear_velocity( linear_distance, smooth_duration=0.500, sampling_frequency=29 ): - smoothed_linear_distance = gaussian_filter1d( linear_distance, smooth_duration * sampling_frequency ) @@ -184,7 +183,9 @@ def convert_linear_distance_to_linear_position( linear_position = linear_distance.copy() n_edges = len(edge_order) if isinstance(spacing, int) | isinstance(spacing, float): - spacing = [spacing,] * (n_edges - 1) + spacing = [ + spacing, + ] * (n_edges - 1) for prev_edge, cur_edge, space in zip(edge_order[:-1], edge_order[1:], spacing): is_cur_edge = edge_id == cur_edge @@ -256,7 +257,9 @@ def _calulcate_linear_position( n_edges = len(edge_order) if isinstance(edge_spacing, int) | isinstance(edge_spacing, float): - edge_spacing = [edge_spacing,] * (n_edges - 1) + edge_spacing = [ + edge_spacing, + ] * (n_edges - 1) for start_linear_position, start_linear_distance, cur_edge in zip( node_linear_position[:, 0], node_linear_distance[:, 0], edge_order @@ -417,8 +420,7 @@ def get_interpolated_position_dataframe( def get_well_locations(epoch_key, animals): - """Retrieves the 2D coordinates for each well. - """ + """Retrieves the 2D coordinates for each well.""" animal, day, epoch = epoch_key task_file = get_data_structure(animals[animal], day, "task", "task") linearcoord = task_file[epoch - 1]["linearcoord"][0, 0].squeeze(axis=0) @@ -476,7 +478,7 @@ def make_track_graph(epoch_key, animals): _, unique_ind = np.unique(nodes, return_index=True, axis=0) nodes = nodes[np.sort(unique_ind)] - edges = np.zeros(track_segments.shape[:2], dtype=np.int) + edges = np.zeros(track_segments.shape[:2], dtype=int) for node_id, node in enumerate(nodes): edge_ind = np.nonzero(np.isin(track_segments, node).sum(axis=2) > 1) edges[edge_ind] = node_id diff --git a/loren_frank_data_processing/track_segment_classification.py b/loren_frank_data_processing/track_segment_classification.py index b5218a7..2b6878a 100644 --- a/loren_frank_data_processing/track_segment_classification.py +++ b/loren_frank_data_processing/track_segment_classification.py @@ -5,8 +5,6 @@ import numpy as np import scipy.stats -np.warnings.filterwarnings("ignore") - def get_track_segments_from_graph(track_graph): """ @@ -59,7 +57,7 @@ def project_points_to_segment(track_segments, position): """ segment_diff = np.diff(track_segments, axis=1).squeeze(axis=1) - sum_squares = np.sum(segment_diff ** 2, axis=1) + sum_squares = np.sum(segment_diff**2, axis=1) node1 = track_segments[:, 0, :] nx = ( np.sum(segment_diff * (position[:, np.newaxis, :] - node1), axis=2) @@ -73,8 +71,7 @@ def project_points_to_segment(track_segments, position): def find_projected_point_distance(track_segments, position): - """ - """ + """ """ return np.linalg.norm( position[:, np.newaxis, :] - project_points_to_segment(track_segments, position), @@ -301,7 +298,7 @@ def viterbi(initial_conditions, state_transition, likelihood): n_time, n_states = log_likelihood.shape posterior = np.zeros((n_time, n_states)) - max_state_ind = np.zeros((n_time, n_states), dtype=np.int) + max_state_ind = np.zeros((n_time, n_states), dtype=int) # initialization posterior[0] = np.log(initial_conditions) + log_likelihood[0] @@ -316,7 +313,7 @@ def viterbi(initial_conditions, state_transition, likelihood): ) # termination - most_probable_state_ind = np.zeros((n_time,), dtype=np.int) + most_probable_state_ind = np.zeros((n_time,), dtype=int) most_probable_state_ind[n_time - 1] = np.argmax(posterior[n_time - 1]) # path back-tracking @@ -383,12 +380,10 @@ def classify_track_segments( def batch_linear_distance(track_graph, projected_track_positions, edge_ids, well_id): - copy_graph = track_graph.copy() linear_distance = [] for (x3, y3), (node1, node2) in zip(projected_track_positions, edge_ids): - x1, y1 = copy_graph.nodes[node1]["pos"] left_distance = sqrt((x3 - x1) ** 2 + (y3 - y1) ** 2) nx.add_path(copy_graph, [node1, "projected"], distance=left_distance)