Files
bio-performx/notebooks/__pycache__/gemini_rer.cpython-312.pyc
T

75 lines
7.2 KiB
Plaintext
Raw Normal View History

2025-11-28 11:44:37 +01:00
Ë
‚l)iã
ó°ddlZddlZdZdZdZdZdZdZ ddZ
e
d d
d d d
ddd¬«Z e j«D]\Z
Zee
de«Œy)éNcóvd|zd|zzd|zz
}|j«jd«r|dzS|dz
S)zQ
Compute predicted RMR with Mifflin St Jeor.
sex: 'male' or 'female'
g$@g@gmg d@)ÚlowerÚ
startswith)Ú weight_kgÚ height_cmÚ age_yearsÚsexÚbases úM/home/oluwasanmi/Documents/Work/MKD/report_generation/notebooks/gemini_rer.pyÚmifflin_st_jeorr
sIð
 ˜d YÑ °y±Ñ @€DØ
‡yyƒ{×јc‰zÐàe‰|Ðócóp||z }|dkrd}||fS|dkrd}||fS|dkrd}||fS|dkrd}||fSd }||fS)
zU
Classify metabolic rate relative to prediction.
Returns (label, ratio).
gffffffæ?z very slowgÍÌÌÌÌÌì?Úslowgš™™™™™ñ?ÚaveragegÍÌÌÌÌÌô?Úfastz very fast©)Úmeasured_kcal_dayÚpredicted_kcal_dayÚratioÚlabels r Úclassify_metabolismrs†ð
Ð 2Ñ 2€Eà ˆt‚|؈ð %ˆ<Ðð
ŠØˆð %ˆ<Ðð
؈ð %ˆ<Ðð
؈ð %ˆ<Ððˆà %ˆrcó¨|dj«j«}||dkr td«tt d|z ««}|dkrd}|S)zB
Derive number of samples that represent about 2 minutes.
úT(sec)rzInvalid time step in T(sec)g^@é)ÚdiffÚmedianÚ
ValueErrorÚintÚround)ÚdfÚdtÚsampless r Úfind_sampling_windowr$&sZð
ˆH‰× Ñ Ó × #Ñ #Ó %€BØ €zR˜1Д%˜ 
Ó$€GØ‚{ØˆØ €NrcóÜgd¢}gd¢}||j||¬«j«}||j||¬«j«}|jdd¬«}|j «j «}|j |j«}t||z
dzd«} |}
t|dj| «} t|dj|
«} || | fS) z
Find the most stable 2-minute window using rolling standard deviation.
Returns:
means_series, t_start, t_end
© ú VO2(ml/min)ú VCO2(ml/min)ú VE(l/min)úVT(l)úBF(bpm)ú EE(kcal/min)ÚRERúCARBS(%)úFAT(%))r'r(r)r*r+)Ú min_periodsrF)ÚaxisÚskipnarr) ÚrollingÚmeanÚstdÚsumÚdropnaÚidxminÚlocÚcopyÚmaxÚfloatÚiloc)
r!Úwindow_samplesÚ cols_meanÚcols_stdÚ roll_meanÚroll_stdÚstability_scoreÚbest_idxÚ means_seriesÚ start_idxÚend_idxÚt_startÚt_ends
r Úrolling_stable_windowrJ4ò
€Iò€Hð9‘
×% nÀ.ÐX€IØ(‰|×# NÀÐU€Hð—l‘l¨°%8€Oð×'×0€Hà—=Ñ1€LäH˜~ÑÑ1°1Ó5€IØ€GäBxL×% 1€GÜ "X,×#  -€Eà ˜  'rcóè|d|k\|d|kz}|j|j«}|jr td«gd¢}||j «}|t |«t |«fS)zA
Compute mean values inside a user-selected time window.
rz-Manual window has no rows inside T(sec) ranger&)r9r:Úemptyrr4r<)r!rHrIÚmaskÚslice_dfÚcolsÚmeanss r Úmanual_window_meansrQbsyð
ˆx‰L˜GÑ ¨8© ¸Ñ(=Ñ >€DØv‰vd‰|× Ñ Ó"€Hà‡~‚~ÜÐ
€Dð
T‰N× Ñ Ó !€EØ ”%˜“.¤%¨£,Ð .rcóÌtj|d¬«}gd¢}|D]}tj||d¬«||<Œ!|jddg¬«j d ¬
«}|S) z)
Load and clean a PNOE CSV file.
ú;)Úsep)
rr'r(r-r)r*r+r,r.r/Úcoerce)Úerrorsr'r,)ÚsubsetT)Údrop)ÚpdÚread_csvÚ
to_numericr7Ú reset_index)Úpathr!Ú numeric_colsÚcols r Ú
load_pnoe_csvr`|siô
T˜sÔ #€Bò €LóˆÜ—-‘-  3¡°Ôˆ3Šðð
˜=¨.Ð9ˆÓ :× FÑ FÈDÐ FÓ Q€BØ
€Ircóžt|«}t|«} t|| «\}
} } d}
d}d}||\}}t|||«\}
}}d}|
}|}|}nd}|
}| }| }t |d«}|dz}t ||||«}t
||«\}}d}|||||||||||||dœ
}|j|d|
| | ««|j|d|
||««|S)
Analyze resting RMR from a PNOE CSV file.
manual_window:
None for automatic stable window
or (t_start_sec, t_end_sec) for user-chosen window
manualÚautor,g€–@có`|iS|d||d||dt|d«dz |dt|d«dz |dt|d «|d
t|d «|d t|d
«|dt|d«|dt|d«|dt|d«|dt|d«i S)_window_start_secÚ_window_end_secÚ
_VO2_L_minr'g@ _VCO2_L_minr(Ú _VE_L_minr)Ú_VT_Lr*Ú_BF_bpmr+Ú_RERr-Ú _Fat_percentr/Ú