Skip to content

Commit 80772b1

Browse files
committed
Forgot some renaming of the variables to match the rest of the script. My bad!
1 parent 2478942 commit 80772b1

File tree

2 files changed

+882
-17
lines changed

2 files changed

+882
-17
lines changed

src/jdb_to_nwb/convert_photometry.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def import_ppd(ppd_file_path):
342342
'''
343343
Credit to the homie: https://github.com/ThomasAkam/photometry_preprocessing.git
344344
I eddited it so that his function only retuns the data dictionary without the filtered data.
345-
Raw data is filtered later/separately using the processppdphotometry function.
345+
Raw data is filtered later/separately using the process_ppd_photometry function.
346346
347347
Function to import pyPhotometry binary data files into Python. Returns a dictionary with the
348348
following items:
@@ -417,7 +417,7 @@ def import_ppd(ppd_file_path):
417417
data_dict.update(header_dict)
418418
return data_dict
419419

420-
def processppdphotometry(ppd_file_path, nwbfile: NWBFile, metadata: dict):
420+
def process_ppd_photometry(ppd_file_path, nwbfile: NWBFile, metadata: dict):
421421
"""
422422
Process pyPhotometry data from a .ppd file and add the processed signals to the NWB file.
423423
"""
@@ -435,22 +435,22 @@ def processppdphotometry(ppd_file_path, nwbfile: NWBFile, metadata: dict):
435435
# low pass at 10Hz to remove high frequency noise
436436
print('Filtering data...')
437437
b,a = butter(2, 10, btype='low', fs=sampling_rate)
438-
GACh_denoised = filtfilt(b,a, raw_green)
439-
rDA3m_denoised = filtfilt(b,a, raw_red)
438+
green_denoised = filtfilt(b,a, raw_green)
439+
red_denoised = filtfilt(b,a, raw_red)
440440
ratio_denoised = filtfilt(b,a, relative_raw_signal)
441441
denoised_405 = filtfilt(b,a, raw_405)
442442
# high pass at 0.001Hz which removes the drift due to bleaching, but will also remove any physiological variation in the signal on very slow timescales.
443443
b,a = butter(2, 0.001, btype='high', fs=sampling_rate)
444-
GACh_highpass = filtfilt(b,a, GACh_denoised, padtype='even')
445-
rDA3m_highpass = filtfilt(b,a, rDA3m_denoised, padtype='even')
444+
green_highpass = filtfilt(b,a, green_denoised, padtype='even')
445+
red_highpass = filtfilt(b,a, red_denoised, padtype='even')
446446
ratio_highpass = filtfilt(b,a, ratio_denoised, padtype='even')
447447
highpass_405 = filtfilt(b,a, denoised_405, padtype='even')
448448

449449
# Z-score of each signal to normalize the data
450450
print('Z-scoring data...')
451-
green_zscored = np.divide(np.subtract(GACh_highpass,GACh_highpass.mean()),GACh_highpass.std())
451+
green_zscored = np.divide(np.subtract(green_highpass,green_highpass.mean()),green_highpass.std())
452452

453-
red_zscored = np.divide(np.subtract(rDA3m_highpass,rDA3m_highpass.mean()),rDA3m_highpass.std())
453+
red_zscored = np.divide(np.subtract(red_highpass,red_highpass.mean()),red_highpass.std())
454454

455455
zscored_405 = np.divide(np.subtract(highpass_405,highpass_405.mean()),highpass_405.std())
456456

@@ -466,63 +466,63 @@ def processppdphotometry(ppd_file_path, nwbfile: NWBFile, metadata: dict):
466466

467467
raw_470_response_series = FiberPhotometryResponseSeries(
468468
name="raw_470",
469-
description="Raw ACh signal @470 nm",
469+
description="Raw 470 nm",
470470
data=raw_green.T[0],
471471
unit="V",
472472
rate=float(sampling_rate),
473473
)
474474

475475
z_scored_470_response_series = FiberPhotometryResponseSeries(
476476
name="z_scored_470",
477-
description="Z-scored ACh signal @470 nm",
477+
description="Z-scored 470 nm",
478478
data=green_zscored.T[0],
479479
unit="z-score",
480480
rate=float(sampling_rate),
481481
)
482482

483483
raw_405_response_series = FiberPhotometryResponseSeries(
484484
name="raw_405",
485-
description="Raw ACh signal @405 nm",
485+
description="Raw 405 nm",
486486
data=raw_405.T[0],
487487
unit="V",
488488
rate=float(sampling_rate),
489489
)
490490

491491
z_scored_405_response_series = FiberPhotometryResponseSeries(
492492
name="zscored_405",
493-
description="Z-scored ACh signal @ 405nm. This is used to calculate the ratiometric index when using GRAB-ACh3.8",
493+
description="Z-scored 405nm. This is used to calculate the ratiometric index when using GRAB-ACh3.8",
494494
data=zscored_405.T[0],
495495
unit="z-score",
496496
rate=float(sampling_rate),
497497
)
498498

499499
raw_565_response_series = FiberPhotometryResponseSeries(
500500
name="raw_565",
501-
description="Raw DA signal @565 nm",
501+
description="Raw 565 nm",
502502
data=raw_red.T[0],
503503
unit="V",
504504
rate=float(sampling_rate),
505505
)
506506

507507
z_scored_565_response_series = FiberPhotometryResponseSeries(
508508
name="zscored_565",
509-
description="Z-scored DA signal @ 565nm",
509+
description="Z-scored 565nm",
510510
data=red_zscored.T[0],
511511
unit="z-score",
512512
rate=float(sampling_rate),
513513
)
514514

515515
raw_ratio_response_series = FiberPhotometryResponseSeries(
516516
name="raw_470/405",
517-
description="Raw ratiometric index of ACh signal @ 470nm and 405nm",
517+
description="Raw ratiometric index of 470nm and 405nm",
518518
data=relative_raw_signal.T[0],
519519
unit="V",
520520
rate=float(sampling_rate),
521521
)
522522

523523
z_scored_ratio_response_series = FiberPhotometryResponseSeries(
524524
name="zscored_470/405",
525-
description="Z-scored ratiometric index of ACh3.8 signal @ 470nm and 405nm",
525+
description="Z-scored ratiometric index of 470nm and 405nm",
526526
data=ratio_zscored.T[0],
527527
unit="z-score",
528528
rate=float(sampling_rate),
@@ -602,7 +602,7 @@ def add_photometry(nwbfile: NWBFile, metadata: dict):
602602
# Process ppd file from pyPhotometry
603603
print("Processing ppd file from pyPhotometry...")
604604
ppd_file_path = metadata["photometry"]["ppd_file_path"]
605-
signals = processppdphotometry(ppd_file_path)
605+
signals = process_ppd_photometry(ppd_file_path)
606606
# TODO for Jose - add pyPhotometry processing here!!
607607
# Probably add the processing functions above and just call them here
608608

0 commit comments

Comments
 (0)