This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cross corr should work with stimulus data, untested
- Loading branch information
1 parent
bbd9c0b
commit f24d774
Showing
4 changed files
with
141 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
@author: kushal | ||
Chatzigeorgiou Group | ||
Sars International Centre for Marine Molecular Biology | ||
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 | ||
""" | ||
|
||
import pandas as pd | ||
import numpy as np | ||
from typing import Tuple, List | ||
|
||
|
||
def get_binary_stims( | ||
stim_df: pd.DataFrame, | ||
index_size: int, | ||
start_offset: int = 0, | ||
end_offset: int = 0 | ||
) -> Tuple[np.ndarray, List[str]]: | ||
""" | ||
""" | ||
|
||
stims = stim_df['name'].unique() | ||
|
||
if index_size < stim_df['end'].max(): | ||
index_size = int(stim_df['end'].max()) | ||
|
||
binarized_arrays = [] | ||
|
||
for stimulus in stims: | ||
sub_df = stim_df[stim_df['name'] == stimulus] | ||
|
||
# One binary stim array for each stimulus in the `stim_df` | ||
stim_array = np.empty(index_size, dtype=np.uint8) | ||
stim_array[:] = 0 | ||
|
||
# fill stim_array | ||
# stim_array is used for fancy indexing | ||
for ix, r in sub_df.iterrows(): # iterate through the stimulus periods | ||
# apply any offsets | ||
start_ix = r['start'] + start_offset | ||
end_ix = r['end'] + end_offset | ||
|
||
# set this period to 1 in the array | ||
stim_array[int(start_ix):int(end_ix)] = 1 | ||
|
||
binarized_arrays.append(stim_array) | ||
|
||
return np.vstack(binarized_arrays), stims |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters