-
Notifications
You must be signed in to change notification settings - Fork 2
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
Added the pyphotometry preprocessing steps. There is a function calle… #21
base: main
Are you sure you want to change the base?
Conversation
…d 'import_ppd' that is needed to import .ppd data. I included it in the description of the processppdphotometry function. Is this correct?
src/jdb_to_nwb/convert_photometry.py
Outdated
requires the import_ppd function from the data_import.py script | ||
The code needed is below. | ||
|
||
def import_ppd(file_path, low_pass=20, high_pass=15.9): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the import_ppd function needs to be on its own instead of in a comment - otherwise the processppdphotometry function won't know what import_ppd means and this will break when you run it
src/jdb_to_nwb/convert_photometry.py
Outdated
sampling_rate = ppd_data['sampling_rate'] | ||
|
||
b,a = butter(2, 10, btype='low', fs=sampling_rate) | ||
GACh_denoised = filtfilt(b,a, raw_green) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name these green_denoised and red_denoised instead of ACh and DA specific because this pipeline should work regardless of the identity of the red/green signals
src/jdb_to_nwb/convert_photometry.py
Outdated
ratio_zscored = np.divide(np.subtract(ratio_highpass,ratio_highpass.mean()),ratio_highpass.std()) | ||
|
||
return {"green_zscored": green_zscored, "red_zscored": red_zscored, "ratio_zscored": ratio_zscored, "zscored_405": zscored_405} | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete pass - doesn't do anything bc you have already returned a dict
src/jdb_to_nwb/convert_photometry.py
Outdated
@@ -336,6 +336,141 @@ def airPLS(data, lambda_=1e8, max_iterations=50): | |||
weights[-1] = weights[0] | |||
return baseline | |||
|
|||
def processppdphotometry(ppd_file_path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick but I would rename this process_ppd_photometry for readability and to match style with the other function names
src/jdb_to_nwb/convert_photometry.py
Outdated
|
||
ratio_zscored = np.divide(np.subtract(ratio_highpass,ratio_highpass.mean()),ratio_highpass.std()) | ||
|
||
return {"green_zscored": green_zscored, "red_zscored": red_zscored, "ratio_zscored": ratio_zscored, "zscored_405": zscored_405} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also return port visit times for alignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Added some minor comments
@@ -395,9 +601,11 @@ def add_photometry(nwbfile: NWBFile, metadata: dict): | |||
elif "ppd_file_path" in metadata["photometry"]: | |||
# Process ppd file from pyPhotometry | |||
print("Processing ppd file from pyPhotometry...") | |||
|
|||
ppd_file_path = metadata["photometry"]["ppd_file_path"] | |||
signals = process_ppd_photometry(ppd_file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change returned values and arguments to match the function definition
signals = process_ppd_photometry(ppd_file_path) | |
sampling_rate, visits = process_ppd_photometry(nwbfile, ppd_file_path) |
# TODO for Jose - add pyPhotometry processing here!! | ||
# Probably add the processing functions above and just call them here | ||
|
||
raise NotImplementedError("pyPhotometry processing is not yet implemented.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove TODO and NotImplementedError because it is now implemented
# TODO for Jose - add pyPhotometry processing here!! | |
# Probably add the processing functions above and just call them here | |
raise NotImplementedError("pyPhotometry processing is not yet implemented.") |
# Return port visits in downsampled photometry time (250 Hz) to use for alignment | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe pyPhotometry is 86(?) Hz instead of 250
# Return port visits in downsampled photometry time (250 Hz) to use for alignment | |
# Return port visits in downsampled photometry time (86 Hz) to use for alignment |
data_dict.update(header_dict) | ||
return data_dict | ||
|
||
def process_ppd_photometry(ppd_file_path, nwbfile: NWBFile, metadata: dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove metadata here bc we don't use it. Also put nwbfile as the first argument for consistency
def process_ppd_photometry(ppd_file_path, nwbfile: NWBFile, metadata: dict): | |
def process_ppd_photometry(nwbfile: NWBFile, ppd_file_path): |
# Add photometry metadata to the NWB | ||
print("Adding photometry metadata to NWB ...") | ||
add_photometry_metadata(NWBFile, metadata) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this because I will reorganize in the next PR to add it separately (outside of either the LabVIEW or pyPhotometry specific processing)
# Add photometry metadata to the NWB | |
print("Adding photometry metadata to NWB ...") | |
add_photometry_metadata(NWBFile, metadata) |
zscored_405 = np.divide(np.subtract(highpass_405,highpass_405.mean()),highpass_405.std()) | ||
|
||
ratio_zscored = np.divide(np.subtract(ratio_highpass,ratio_highpass.mean()),ratio_highpass.std()) | ||
print('Done processing photometry data! Returning z-scored signals...') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but changing this bc we don't actually return them and the next comment is "adding to NWB" which is what we actually do next
print('Done processing photometry data! Returning z-scored signals...') | |
print('Done processing photometry data!') |
…d 'import_ppd' that is needed to import .ppd data. I included it in the description of the processppdphotometry function. Is this correct?