From d12969d352a3ad7f1594aefef66cdb37b1521c88 Mon Sep 17 00:00:00 2001
From: Gorka Fraga Gonzalez <gorka.fragagonzalez@uzh.ch>
Date: Fri, 6 Sep 2024 17:35:22 +0200
Subject: [PATCH] added filename of scan_list tablbes as input in input_mice,
 corrected publication code to merge and display as tabs

---
 .../Publication_page.qmd                      | 74 +++++++++++++------
 .../input_mice.csv                            | 16 ++--
 2 files changed, 59 insertions(+), 31 deletions(-)

diff --git a/webpage_contents/publications/20240901_Marta_GironaAlarcon/Publication_page.qmd b/webpage_contents/publications/20240901_Marta_GironaAlarcon/Publication_page.qmd
index 716d44b..3acf2d2 100644
--- a/webpage_contents/publications/20240901_Marta_GironaAlarcon/Publication_page.qmd
+++ b/webpage_contents/publications/20240901_Marta_GironaAlarcon/Publication_page.qmd
@@ -13,35 +13,39 @@ author:
     orcid: 0000-0003-2665-0995
     affiliations:
       - name: The Interface Group, Institute of Physiology, University of Zurich
-
+format:
+  html:
+    grid: 
+      body-width: 1500px
 ---
-## Setup
-[test_link](https://gitlab.uzh.ch/)
 
 ### Images
 
-
 ### Materials and equipment table
 
 ## Supplemental Results
 
 ### Experiment 2: CSF spaces segmentation
+
 ![](images/JP26-invivo-2scan-phase3-postinjection-brain-80-90min_web.png){width="600"}
 
 Three dimensional rendering of CSF spaces enclosed in the mouse skull: Infusion of contrast agent in the lateral ventricles during high-resolution synchrotron radiation-based hard X-ray computed tomography imaging allows 3D visualization with virtual slicing in all directions. Lateral ventricles in blue, third ventricle in green, aqueduct in pink and fourth ventricle in yellow.
 
 ### Experiment 4: Contrast agent dynamics during lateral ventricle influsion
-- add movie (link to Zenodo)
+
+-   add movie (link to Zenodo)
 
 ### Experiment 6: Cardiac-gated 3D imaging
-- add movie (link to Zenodo)
+
+-   add movie (link to Zenodo)
 
 ### Experiment 7: Non-periodic ChP movement within the lateral ventricle
-- add movie (link to Zenodo)
+
+-   add movie (link to Zenodo)
 
 ## Discussion: CSF flow back to the infusion cannula
-- add projections movie (link to Zenodo)
 
+-   add projections movie (link to Zenodo)
 
 <!-- Do not edit below this line !! -->
 
@@ -60,7 +64,7 @@ colnames(paths) <- 'Protocols'
 
 # Add HTML code so that it becomes a clickable link 
 paths$Protocols <- paste0('<a href=\'',paths$Protocols,'\' target=\'_blank\'>', paths$Protocols,'</a>')
-
+#file.path(here::here(), apply(folders, 1, paste, collapse = .Platform$file.sep), 'protocols')
 
 # Render table
 DT::datatable(paths, options = list(dom = 't'), escape = FALSE, rownames = FALSE, )
@@ -73,25 +77,49 @@ DT::datatable(paths, options = list(dom = 't'), escape = FALSE, rownames = FALSE
 library(dplyr)
 
 # Take the relevant rows from the tables specified in inputs
-data_used <- list()
+mice_used <- list()
+scans_used <- list()
 for (i in 1:nrow(inputs)){ 
-  row_filepath <- file.path(here::here(), 'experiments',inputs$Data_type[i], inputs$Facility_name_YYYY_month[i], "metadata_tables", inputs$Metadata_file[i]) 
-  data_used[[i]] <- read.csv(row_filepath) %>% filter(Subject_ID == inputs$Subject_ID[i]) # read table and filter subject
+  row_filepath <- file.path(here::here(), 'experiments',inputs$Data_type[i], inputs$Facility_name_YYYY_month[i], "metadata_tables",inputs$Metadata_file_mouse[i]) 
+  mice_used[[i]] <- read.csv(row_filepath) %>% filter(Subject_ID == inputs$Subject_ID[i]) # read table and filter subject
+  mice_used[[i]]$Subject_pubID <- inputs$Subject_pubID[i]  # Add additional input column 
+  mice_used[[i]]$Correction_factor <- inputs$Correction_factor[i] # Add additional input column
   
-  # Add additional columns from 'input_mice' tables into the mouse_list table that will be displayed
-  data_used[[i]]$Subject_pubID <- inputs$Subject_pubID[i]  
-  data_used[[i]]$Correction_factor <- inputs$Correction_factor[i] # Add additional input column
+  # Combine with scan lists for that subject
+  row_filepath_scans <- file.path(here::here(), 'experiments',inputs$Data_type[i], inputs$Facility_name_YYYY_month[i], "metadata_tables",inputs$Metadata_file_scan[i]) 
+  tmp_tbl_scans <- read.csv(row_filepath_scans) %>% filter(Subject_ID == inputs$Subject_ID[i],row)
+  scans_used[[i]] <- full_join(x=mice_used[[i]],
+                          y = tmp_tbl_scans,
+                          by=join_by("Subject_ID"),keep=FALSE)
+              
+   
 }
 
-# Gather all rows elements in a table 
-data_used <- do.call(rbind,data_used) 
+# Gather list elements in a table 
+mice_used <- do.call(rbind,mice_used)
+scans_used <- do.call(rbind,scans_used) 
 
-# Change position of some columns
-data_used <- relocate(data_used, Correction_factor, .before = 7)
-data_used <- relocate(data_used, Subject_pubID, .before = 1)
+#Change position of some columns
+mice_used <- relocate(mice_used, Correction_factor, .before = 7)
+mice_used <- relocate(mice_used, Subject_pubID, .before = 1)
+scans_used <- relocate(scans_used, Correction_factor, .before = 7)
+scans_used <- relocate(scans_used, Subject_pubID, .before = 1)
+
+```
+
+::: {.panel-tabset}
+## Mice and scans info
+```{r}
+DT::datatable(mice_used, filter = 'top', rownames = FALSE)
+
+```
+
+## Mice info
+```{r}
+DT::datatable(scans_used, filter = 'top', rownames = FALSE)
+
+```
 
-#Display  table 
-DT::datatable(data_used, filter = 'top')
 
-``` 
 
+:::
diff --git a/webpage_contents/publications/20240901_Marta_GironaAlarcon/input_mice.csv b/webpage_contents/publications/20240901_Marta_GironaAlarcon/input_mice.csv
index c3e5b7d..8fb4d62 100644
--- a/webpage_contents/publications/20240901_Marta_GironaAlarcon/input_mice.csv
+++ b/webpage_contents/publications/20240901_Marta_GironaAlarcon/input_mice.csv
@@ -1,8 +1,8 @@
-Metadata_file,Data_type,Facility_name_YYYY_month,Subject_ID,Subject_pubID,Correction_factor
-Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse19,Exp1,1.024
-Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse21,Exp2,0.508
-Mouse_list_SPring-8_2023_May.csv,synchrotron_microCT,SPring-8_2023_May,JP28,Exp3,1.024
-Mouse_list_ESRF_2022_June.csv,synchrotron_microCT,ESRF_2022_June,mouse63,Exp4,0.930
-Mouse_list_ESRF_2022_June.csv,synchrotron_microCT,ESRF_2022_June,mouse50,Exp5,1
-Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse17,Exp6,1
-Mouse_list_CLS_2023_November.csv,synchrotron_microCT,CLS_2023_November,subjCA019,Exp7,N/A
\ No newline at end of file
+Metadata_file_scan, Metadata_file_mouse,Data_type,Facility_name_YYYY_month,Subject_ID,Subject_pubID,Correction_factor
+Scan_list_ESRF_2021_November.csv,Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse19,Exp1,1.024
+Scan_list_ESRF_2021_November.csv,Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse21,Exp2,0.508
+Scan_list_SPring-8_2023_May.csv,Mouse_list_SPring-8_2023_May.csv,synchrotron_microCT,SPring-8_2023_May,JP28,Exp3,1.024
+Scan_list_ESRF_2022_June.csv,Mouse_list_ESRF_2022_June.csv,synchrotron_microCT,ESRF_2022_June,mouse63,Exp4,0.930
+Scan_list_ESRF_2022_June.csv,Mouse_list_ESRF_2022_June.csv,synchrotron_microCT,ESRF_2022_June,mouse50,Exp5,1
+Scan_list_ESRF_2021_November.csv,Mouse_list_ESRF_2021_November.csv,synchrotron_microCT,ESRF_2021_November,Mouse17,Exp6,1
+Scan_list_CLS_2023_November.csv,Mouse_list_CLS_2023_November.csv,synchrotron_microCT,CLS_2023_November,subjCA019,Exp7,N/A
\ No newline at end of file
-- 
GitLab