<jupyter_start><jupyter_text>- do curve fitting and linearization in radiance rather than lux- match top radiance for chirp in different wavelengths- multiply by parametric output of beta function- inverse function<jupyter_code>from colour.plotting import plot_chromaticity_diagram_CIE1931

from pyplr.CIE import get_CIE_CMF
from pyplr.spectools import spec_to_xyz

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


cmf = get_CIE_CMF(asdf=True, binwidth=1)

xyz = cc.data.loc[:, 4095, :].apply(lambda row: spec_to_xyz(row.to_numpy(), cmf), axis=1)
xyz = xyz.append(xyz.loc[0]).reset_index()
xyz

# set up figure
f, ax = plt.subplots(1, 1, figsize=(7,7))

# plotting the *CIE xy* chromaticity coordinates.
plot_chromaticity_diagram_CIE1931(standalone=False, axes=ax, title=False, show_spectral_locus=True)
ax.set_xlim((-.15,.9))
ax.set_ylim((-.1,1))
ax.plot(xyz['X'], xyz['Y'], color='k', lw=1.5, marker='o', markersize=6)
for item in ax.texts:
    item.set_fontsize(12)
f.savefig('../img/CIE_gamut.tiff', dpi=300, bbox_inches='tight')
f, ax = plt.subplots(1, 1, figsize=(12,4))
d = cc.lkp.loc[:,4095, :]
for led, df in d.iterrows():
    color = colors[led]
    df.plot(c=color, lw=1, label=led)
ax.legend(title='Channel')
ax.set_xlabel('Wavelength (nm)')
ax.set_ylabel('SPD (W/m$^2$/nm)')
f.savefig('../img/STLAB_SPDs.svg', bbox_inches='tight')
sns.set_context('poster')
f, ax = plt.subplots(1, 1, figsize=(12,4))
d = cc.lkp.loc[:,4095, :]

for led, df in d.iterrows():
    color = colors[led]
    df.plot(c=color, lw=3, label=led)
#ax.legend(title='Channel')
ax.set_xlabel('Wavelength (nm)')
ax.set_ylabel('SPD (W/m$^2$/nm)')
f.savefig('../img/STLAB_SPDs_poster.tiff', dpi=300, bbox_inches='tight')
import os
import os.path as op
import glob

import numpy as np
import pandas as pd
import seaborn as sns

datadir = '../data/pupil_core_camera_sync_tests'
recordings = glob.glob(datadir + '/**/**/**/annotations.csv')

data = pd.DataFrame()
for rec in recordings:
    # Load annotations and get camera timestamps for detected light flash
    df = pd.read_csv(rec)
    eye_0 = df.loc[df.label=='light_on_eye_0', 'timestamp'].to_numpy()
    eye_1 = df.loc[df.label=='light_on_eye_1', 'timestamp'].to_numpy() 
    world = df.loc[df.label=='light_on_world', 'timestamp'].to_numpy()
    
    # Calculate timestamp differences and make DataFrame
    diffs = (pd.DataFrame(data=[(eye_0-world)*1000,
                                (eye_1-world)*1000,
                                (eye_0-eye_1)*1000],
                          index=['eye0 - world',
                                 'eye1 - world',
                                 'eye0 - eye1'])
               .T.melt(var_name='Comparison', 
                       value_name='Timestamp difference (ms)'))
    
    # Add categories for operating system and frames per second
    diffs['OS'] = 'macOS' if 'mac' in rec else 'Windows'
    diffs['FPS'] = '120' if '120_fps' in rec else '60'
    diffs.to_csv(op.join(op.dirname(rec), 'annotation_timestamp_diffs.csv'))
    
    # Append to master frame
    data = data.append(diffs)
data
sns.set_context('paper', font_scale=2)
g = sns.catplot(data=data, 
                x='Comparison', 
                y='Timestamp difference (ms)', 
                row='OS', 
                col='FPS',
                kind='box', 
                order=['eye0 - world', 'eye1 - world', 'eye0 - eye1'],
                flierprops={'markersize':3})
g.savefig('./Pupil_Core_camera_sync.tiff', dpi=600)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15628571428571428, 'fraction_numerical': 0.028285714285714286, 'mean_word_length': 3.2436363636363637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '184640', 'license': 'MIT', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1279, 'n_words': 265, 'path': 'notebooks/manuscript_figures.ipynb', 'repo_name': 'PyPlr/cvd_pupillometry', 'size': '3500'}