From 0dcbf5cd356818055a53a19305a1f0fe00401a81 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Mon, 28 Feb 2022 23:09:11 -0500 Subject: [PATCH] Day 7 pages --- _config.yml | 4 ---- _toc.yml | 4 ++++ pages/model_one_voxel.Rmd | 38 ++++++------------------------------- pages/multi_multiply.Rmd | 36 +++++------------------------------ pages/new_cond.txt | 1 + pages/non_tr_onsets.Rmd | 36 +++++------------------------------ pages/test_one_voxel.Rmd | 40 +++++++-------------------------------- 7 files changed, 28 insertions(+), 131 deletions(-) create mode 120000 pages/new_cond.txt diff --git a/_config.yml b/_config.yml index 133d37e8..aa23ce0e 100644 --- a/_config.yml +++ b/_config.yml @@ -69,12 +69,9 @@ exclude_patterns: - pages/markdown.md - pages/mentors.md - pages/methods_vs_functions.Rmd - - pages/model_one_voxel.Rmd - pages/multi_model_homework.md - - pages/multi_multiply.Rmd - pages/nans.md - pages/newaxis.Rmd - - pages/non_tr_onsets.Rmd - pages/numpy_diag.Rmd - pages/numpy_meshgrid.Rmd - pages/numpy_random.Rmd @@ -99,7 +96,6 @@ exclude_patterns: - pages/subplots.Rmd - pages/subtract_mean_math.md - pages/subtract_means.Rmd - - pages/test_one_voxel.Rmd - pages/topics.md - pages/tr_and_headers.Rmd - pages/two_dunders.md diff --git a/_toc.yml b/_toc.yml index 8a287fb2..c379e9eb 100644 --- a/_toc.yml +++ b/_toc.yml @@ -33,6 +33,10 @@ parts: - caption: Hemodynamic response modeling chapters: - file: pages/convolution_background + - file: pages/model_one_voxel + - file: pages/test_one_voxel + - file: pages/multi_multiply + - file: pages/non_tr_onsets - caption: Code organization and collaboration chapters: # - file: pages/git_walk_through diff --git a/pages/model_one_voxel.Rmd b/pages/model_one_voxel.Rmd index 546283d0..c31169c9 100644 --- a/pages/model_one_voxel.Rmd +++ b/pages/model_one_voxel.Rmd @@ -6,11 +6,13 @@ jupyter: format_name: rmarkdown format_version: '1.2' jupytext_version: 1.11.5 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 --- -$\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}$ - -## Modeling a single voxel +# Modeling a single voxel Earlier – Voxel time courses – we were looking at a single voxel time course. @@ -30,7 +32,7 @@ we discovered in First go at brain activation exercise: ```{python} img = nib.load('ds114_sub009_t2r1.nii') -data = img.get_data() +data = img.get_fdata() data = data[..., 4:] ``` @@ -116,31 +118,3 @@ print(np.sum(e_vec ** 2)) plt.plot(voxel_time_course) plt.plot(y_hat) ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pages/multi_multiply.Rmd b/pages/multi_multiply.Rmd index 96575413..9244500e 100644 --- a/pages/multi_multiply.Rmd +++ b/pages/multi_multiply.Rmd @@ -6,11 +6,13 @@ jupyter: format_name: rmarkdown format_version: '1.2' jupytext_version: 1.11.5 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 --- -$\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}$ - -## Estimation for many voxels at the same time +# Estimation for many voxels at the same time We often want to fit the same design to many different voxels. @@ -66,31 +68,3 @@ betas ``` Of course this is true for any number of columns of Y. - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pages/new_cond.txt b/pages/new_cond.txt new file mode 120000 index 00000000..02451ddb --- /dev/null +++ b/pages/new_cond.txt @@ -0,0 +1 @@ +../data/new_cond.txt \ No newline at end of file diff --git a/pages/non_tr_onsets.Rmd b/pages/non_tr_onsets.Rmd index 0b4bf396..4c8dd58b 100644 --- a/pages/non_tr_onsets.Rmd +++ b/pages/non_tr_onsets.Rmd @@ -6,11 +6,13 @@ jupyter: format_name: rmarkdown format_version: '1.2' jupytext_version: 1.11.5 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 --- -$\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}$ - -## Using onsets that do not start on a TR +# Using onsets that do not start on a TR You’ll need the file `new_cond.txt` to type along with this demonstration. @@ -184,31 +186,3 @@ plt.plot(tr_times[:20], tr_hemo[:20], 'x:') plt.xlabel('Time (seconds)') plt.ylabel('Convolved values at TR onsets') ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pages/test_one_voxel.Rmd b/pages/test_one_voxel.Rmd index 44c2b48a..655545eb 100644 --- a/pages/test_one_voxel.Rmd +++ b/pages/test_one_voxel.Rmd @@ -6,11 +6,13 @@ jupyter: format_name: rmarkdown format_version: '1.2' jupytext_version: 1.11.5 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 --- -$\newcommand{L}[1]{\| #1 \|}\newcommand{VL}[1]{\L{ \vec{#1} }}\newcommand{R}[1]{\operatorname{Re}\,(#1)}\newcommand{I}[1]{\operatorname{Im}\, (#1)}$ - -## Testing a single voxel +# Testing a single voxel A short ago (Modeling a single voxel), we were modeling a single voxel time course. @@ -27,7 +29,7 @@ np.set_printoptions(precision=4) ```{python} import nibabel as nib img = nib.load('ds114_sub009_t2r1.nii') -data = img.get_data() +data = img.get_fdata() data = data[..., 4:] ``` @@ -155,7 +157,7 @@ p = 1 - ltp # upper tail p p ``` -## Compare our manual estimation to R +# Compare our manual estimation to R Finally let’s save the voxel time course for us to compare this analysis to the `lm` estimation in R: @@ -178,31 +180,3 @@ convolved = convolved[-(1:4)] res = lm(voxels ~ convolved) print(summary(res)) ``` - - - - - - - - - - - - - - - - - - - - - - - - - - - -