Skip to content

Commit

Permalink
add CITATION.cff /JTM
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmbeta committed Aug 6, 2021
1 parent 6842466 commit 8ede4a1
Show file tree
Hide file tree
Showing 20 changed files with 2,751 additions and 5,930 deletions.
13 changes: 13 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cff-version: 1.0.0
message: "If you use this software, please cite it as below."
authors:
- family-names: Martin
given-names: Joel, T.
orcid: https://orcid.org/0000-0002-4475-3835
- family-names: Spitschan
given-names: Manuel
orcid: https://orcid.org/0000-0002-8572-9268
title: "PyPlr"
version: 1.0.0
doi: 10.5281/zenodo.1234
date-released: 2017-12-18
99 changes: 84 additions & 15 deletions docs/05d_pipr_stlab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,40 +205,84 @@
"Now we are ready to run the protocol. For optimal results, do this after a 20-minute period of dark adatation.\n",
"\n",
"```Python\n",
"import os\n",
"from time import sleep\n",
"from random import shuffle\n",
"import random\n",
"\n",
"from pyplr.pupil import PupilCore\n",
"from pyplr.stlab import SpectraTuneLab\n",
"from pyplr.protocol import input_subject_id, subject_dir\n",
"\n",
"# Make list of stims\n",
"stims = ['1s_blue.dsf', '1s_red.dsf'] * 3\n",
"shuffle(stims)\n",
"# Timing function for experimenter feedback\n",
"def timer(increment=1, seconds=0, message='Waiting...'):\n",
" print(message)\n",
" while seconds > 0:\n",
" print(f'\\t{seconds} seconds left...')\n",
" sleep(increment)\n",
" seconds -= increment\n",
"\n",
"# Specify measurement period and wait between trials (60 s each)\n",
"PIPR_MEASUREMENT_PERIOD = 60\n",
"INTERTRIAL_INTERVAL = 60 \n",
"\n",
"# List of stims, x3 red and blue, random order of presentation\n",
"stims = ['./stimuli/1s_blue.dsf', './stimuli/1s_red.dsf'] * 3\n",
"random.shuffle(stims)\n",
"\n",
"# Set up subject and recording\n",
"subject_id = input_subject_id()\n",
"subj_dir = subject_dir(subject_id)\n",
"\n",
"# Connect to Pupil Core\n",
"p = PupilCore()\n",
"\n",
"# Connect to stlab\n",
"d = SpectraTuneLab(password='83e47941d9e930f6')\n",
"d = SpectraTuneLab(password='****************)')\n",
"\n",
"# Start recording\n",
"p.command('R {}'.format(os.getcwd()))\n",
"p.command('R {}'.format(subj_dir))\n",
"\n",
"# Wait a few seconds\n",
"sleep(5.) \n",
"timer(seconds=5)\n",
"\n",
"# Trial incrementor variable\n",
"trial_num = 0\n",
"\n",
"# Loop over the list of stims\n",
"for stim in stims:\n",
"while len(stims) > 0:\n",
" \n",
" # Update trial number\n",
" trial_num += 1\n",
" \n",
" # Pop next stim from the list of stims\n",
" stim = stims.pop(0) \n",
" \n",
" # Print status update for trial\n",
" print('{}\\n{:*^60s}\\n{}'.format(\n",
" '*'*60, ' ' + 'Trial number: ' + str(trial_num) + ' ', '*'*60))\n",
" print('Stimulus--> {}\\nList of stims--> {}'.format(stim, stims))\n",
" print('{}'.format('-'*60)) \n",
" \n",
" # Load video file and create trigger with metadata\n",
" vf = d.load_video_file(stim)\n",
" annotation = {**p.new_annotation('LIGHT_ON'), **vf['metadata']}\n",
" annotation['repeat'] = repeat\n",
" annotation['trial_num'] = trial_num\n",
" \n",
" # Check the eye models. If there is a problem, say 'yes' to\n",
" # refit the model, then ask participants to roll their eyes.\n",
" # When a suitable fit is achieved, press 'Enter' to freeze\n",
" # the 3D models. This will stop the 3D models from updating\n",
" # automatically, which can cause issues with the pupil data.\n",
" p.check_3d_model(eyes=[0,1], alert=False)\n",
" sleep(2)\n",
" \n",
" # Notification of stimulus in 5 - 10 s. On mac, should make a beep sound\n",
" print('\\a')\n",
" \n",
" # Baseline\n",
" sleep(10.)\n",
" # 10 s prestimulus baseline\n",
" timer(seconds=10, message='10 s prestimulus baseline...')\n",
" \n",
" # Set up and start the LightStamper thread \n",
" # Set up and start the light_stamper thread \n",
" lst_future = p.light_stamper(\n",
" threshold=15, annotation=annotation, timeout=6)\n",
" \n",
Expand All @@ -247,11 +291,36 @@
" \n",
" # Play the video file\n",
" d.play_video_file()\n",
" sleep(60.) \n",
"\n",
" timer(seconds=PIPR_MEASUREMENT_PERIOD, message='Collecting data for PIPR. \\\n",
" The participant should be looking straight ahead and hopefully \\\n",
" not blinking too much...')\n",
" \n",
" # Notification that data collection period for the current trial has finished\n",
" print('\\a')\n",
" print('Finished data collection period for current trial')\n",
" \n",
" # Ask whether to repeat last trial. For example, say yes if their eyes were \n",
" # closed during stimulus presentation or if they were closed for long periods\n",
" # during the post stimulus data collection period\n",
" repeat = input('Do you want to repeat the last trial [y/n]? ')\n",
" while repeat != 'y' and repeat != 'n':\n",
" print('I do not understand that...')\n",
" repeat = input('Do you want to repeat the last trial [y/n]? ')\n",
" \n",
" # If 'y' to repeat, then put the stimulus back in the list and reshuffle\n",
" if repeat == 'y':\n",
" stims.append(stim)\n",
" random.shuffle(stims)\n",
" \n",
" # Wait between trials, but only if there is actually another trial in \n",
" # the trial list\n",
" if len(stims) > 0:\n",
" timer(seconds=INTERTRIAL_INTERVAL, message='Wait between trials...')\n",
" \n",
"# Finish recording\n",
"sleep(5.) \n",
"timer(seconds=5, message='Finishing recording...') \n",
"p.command('r')\n",
"\n",
"```"
]
}
Expand Down
477 changes: 477 additions & 0 deletions docs/06d_silent_substitution_STLAB.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/PLR-3000-180-mw.dsf

This file was deleted.

2 changes: 1 addition & 1 deletion examples/PFR/stimuli/PLR-3000-10-mw.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-02-10 13:23:56.116420", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 68, 3, 4, 0, 0, 45, 5, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 68, 3, 4, 0, 0, 45, 5, 0, 0], [0, 68, 3, 4, 0, 0, 45, 5, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-06 10:34:44.790505", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 60, 52, 0, 0, 0, 87, 154, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 60, 52, 0, 0, 0, 87, 154, 0, 0], [0, 60, 52, 0, 0, 0, 87, 154, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
2 changes: 1 addition & 1 deletion examples/PFR/stimuli/PLR-3000-121-mw.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-02-10 13:23:56.140004", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 775, 85, 2, 0, 0, 513, 49, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 775, 85, 2, 0, 0, 513, 49, 0, 0], [0, 775, 85, 2, 0, 0, 513, 49, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-06 10:34:44.776813", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 748, 38, 0, 0, 0, 587, 214, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 748, 38, 0, 0, 0, 587, 214, 0, 0], [0, 748, 38, 0, 0, 0, 587, 214, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
2 changes: 1 addition & 1 deletion examples/PFR/stimuli/PLR-3000-180-mw.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-02-10 13:23:56.147046", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 1105, 143, 0, 0, 0, 740, 70, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 1105, 143, 0, 0, 0, 740, 70, 0, 0], [0, 1105, 143, 0, 0, 0, 740, 70, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-06 10:34:44.767888", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[0, 1176, 18, 0, 0, 0, 855, 225, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 1176, 18, 0, 0, 0, 855, 225, 0, 0], [0, 1176, 18, 0, 0, 0, 855, 225, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
2 changes: 1 addition & 1 deletion examples/PFR/stimuli/PLR-3000-50-mw.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-02-10 13:23:56.129006", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[28, 315, 0, 37, 0, 0, 211, 22, 0, 0]", "pulse_duration": "1000"}, "spectra": [[28, 315, 0, 37, 0, 0, 211, 22, 0, 0], [28, 315, 0, 37, 0, 0, 211, 22, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-06 10:34:44.784227", "creator": "jtm", "protocol": "pulse", "pulse_spec": "[176, 184, 80, 0, 0, 0, 308, 122, 0, 0]", "pulse_duration": "1000"}, "spectra": [[176, 184, 80, 0, 0, 0, 308, 122, 0, 0], [176, 184, 80, 0, 0, 0, 308, 122, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
2 changes: 1 addition & 1 deletion examples/PIPR/stimuli/1s_blue.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-03-30 12:37:54.954983", "creator": "jtm", "color": "blue", "protocol": "pulse", "pulse_spec": "[0, 0, 0, 3708, 0, 0, 0, 0, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 0, 0, 3708, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3708, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-03 20:11:49.677798", "creator": "jtm", "color": "blue", "protocol": "pulse", "pulse_spec": "[0, 0, 0, 3705, 0, 0, 0, 0, 0, 0]", "pulse_duration": "1000"}, "spectra": [[0, 0, 0, 3705, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3705, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
2 changes: 1 addition & 1 deletion examples/PIPR/stimuli/1s_red.dsf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-03-30 12:37:54.970605", "creator": "jtm", "color": "red", "protocol": "pulse", "pulse_spec": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 2899]", "pulse_duration": "1000"}, "spectra": [[0, 0, 0, 0, 0, 0, 0, 0, 0, 2899], [0, 0, 0, 0, 0, 0, 0, 0, 0, 2899], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
{"header": {"version": 1, "model": "VEGA10", "channels": 10, "spectracount": 4, "transitionsCount": 4, "fluxReference": 0, "repeats": 1}, "metadata": {"creation_time": "2021-08-03 20:11:49.682796", "creator": "jtm", "color": "red", "protocol": "pulse", "pulse_spec": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 2897]", "pulse_duration": "1000"}, "spectra": [[0, 0, 0, 0, 0, 0, 0, 0, 0, 2897], [0, 0, 0, 0, 0, 0, 0, 0, 0, 2897], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], "transitions": [{"spectrum": 0, "power": 100, "time": 0, "flags": 0}, {"spectrum": 1, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 2, "power": 100, "time": 1000, "flags": 0}, {"spectrum": 3, "power": 100, "time": 1100, "flags": 0}]}
9 changes: 6 additions & 3 deletions examples/PIPR/stimuli/make_pipr_stimuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
@author: jtm
'''
import matplotlib.pyplot as plt
import seaborn as sns

from pyplr.CIE import get_CIES026
from pyplr.calibrate import CalibrationContext
from pyplr import stlab

sns.set_context('paper', font_scale=2)
sns.set_style('whitegrid')

cc = CalibrationContext(
'../../../data/S2_corrected_oo_spectra.csv', binwidth=1)
Expand All @@ -33,7 +36,7 @@
match_type='irrad')[1]

# plot stims
fig, ax = plt.subplots()
fig, ax = plt.subplots(figsize=(6,4))
sss = get_CIES026(asdf=True, binwidth=1)
ax.plot(cc.lkp.loc[(blue_led, blue_intensity)], c='blue')
ax.plot(cc.lkp.loc[(red_led, red_intensity)], c='red')
Expand All @@ -42,8 +45,8 @@
ax2.plot(sss['Mel'], ls='dashed', c='steelblue')
ax2.set_ylabel('Melanopsin spectral sensitivity', c='steelblue')
ax.set_xlabel('Wavelength (nm)')
ax.set_ylabel('W/m2/nm');
fig.savefig('./pipr_stims.png')
ax.set_ylabel('W/m$^2$/nm');
fig.savefig('./pipr_stims.svg', bbox_inches='tight')

# make video files
blue_spec, red_spec = [0]*10, [0]*10
Expand Down
Binary file modified examples/PIPR/stimuli/pipr_stims.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
989 changes: 65 additions & 924 deletions notebooks/PIPR_analysis.ipynb

Large diffs are not rendered by default.

640 changes: 332 additions & 308 deletions notebooks/PLR-3000-STLAB-settings.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 8ede4a1

Please sign in to comment.