Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Dec 23, 2021
1 parent 7d35d64 commit 5075802
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 134 deletions.
23 changes: 17 additions & 6 deletions notebooks/invivo_Rstat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@
"\n",
"Percentile bootstrapped comparison of dependent samples using Harrell-Davis quantile estimator.\n",
"\n",
"The below cell will perform shift function analysis individually and save `png` and `csv` files."
"The below cell will perform shift function analysis individually and save `png` and `csv` files.\n",
"\n",
"The following cell takes some time to execute."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -96,9 +103,12 @@
"metrics = list(\"MTsat\")\n",
"for (metric in metrics){\n",
"for (sub in subs) {\n",
"T1DIR = paste(derivativesDir,\"T1_SF_PLOTS\",sep=\"\")\n",
"MTRDIR = paste(derivativesDir,\"MTR_SF_PLOTS\",sep=\"\")\n",
"MTSDIR = paste(derivativesDir,\"MTS_SF_PLOTS\",sep=\"\")\n",
"#T1DIR = paste(derivativesDir,\"T1_SF_PLOTS\",sep=\"\")\n",
"#MTRDIR = paste(derivativesDir,\"MTR_SF_PLOTS\",sep=\"\")\n",
"#MTSDIR = paste(derivativesDir,\"MTS_SF_PLOTS\",sep=\"\")\n",
"T1DIR = paste(\"T1_SF_PLOTS\",sep=\"\")\n",
"MTRDIR = paste(\"MTR_SF_PLOTS\",sep=\"\")\n",
"MTSDIR = paste(\"MTS_SF_PLOTS\",sep=\"\")\n",
"dir.create(T1DIR)\n",
"dir.create(MTRDIR)\n",
"dir.create(MTSDIR)\n",
Expand All @@ -109,7 +119,7 @@
"nSamples = 37000\n",
"df <- tibble(N = 1:nSamples)\n",
"for (i in seq(from=1, to=length(sessions), by=1)) {\n",
" curMat <- readMat(paste(derivativesDir,sub,sessions[i],\"/stat/\",sub,\"_\",sessions[i],\"_desc-wm_metrics.mat\",sep = \"\"))\n",
" curMat <- readMat(paste(derivativesDir,sub,\"/\",sessions[i],\"/stat/\",sub,\"_\",sessions[i],\"_desc-wm_metrics.mat\",sep = \"\"))\n",
" curMetric <- curMat[[metric]]\n",
" if (metric == \"MTR\"){\n",
" OUTDIR = MTRDIR\n",
Expand Down Expand Up @@ -359,7 +369,8 @@
"metadata": {},
"outputs": [],
"source": [
"HSFDIR = paste(derivativesDir,\"HSF/\",sep=\"\")\n",
"#HSFDIR = paste(derivativesDir,\"HSF/\",sep=\"\")\n",
"HSFDIR = paste(\"HSF/\",sep=\"\")\n",
"dir.create(HSFDIR)\n",
"\n",
"sessions <- list(\"ses-rth750rev\",\"ses-rthPRIrev\",\"ses-rthSKYrev\",\"ses-vendor750rev\",\"ses-vendorPRIrev\",\"ses-vendorSKYrev\")\n",
Expand Down
129 changes: 9 additions & 120 deletions notebooks/invivo_python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"import math\n",
"from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"from IPython.core.display import display, HTML\n",
"init_notebook_mode(connected=True)\n",
"import scipy.io as sio\n",
"import random\n",
Expand Down Expand Up @@ -128,10 +129,13 @@
"metadata": {},
"outputs": [],
"source": [
"plot_ridgelines('invivo3',sessions,'T1','WM',colors,sides,37000,0.5,2)\n",
"fig = plot_ridgelines('invivo3',sessions,'T1','WM',colors,sides,37000,0.5,2)\n",
"#plot_ridgelines('invivo3',sessions,'MTR','WM',colors,sides,37000,35,70)\n",
"#plot_ridgelines('invivo3',sessions,'MTsat','WM',colors,sides,37000,1,8)\n",
"#plot_ridgelines('invivo3',sessions,'T1','GM',colors,sides,20000,0.5,2) "
"#plot_ridgelines('invivo3',sessions,'T1','GM',colors,sides,20000,0.5,2)\n",
"\n",
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
},
{
Expand Down Expand Up @@ -187,15 +191,7 @@
"\n",
"fig.update_traces(orientation='h')\n",
"fig.update_layout(paper_bgcolor = 'white',plot_bgcolor = 'white',height=800, width=1200)\n",
"fig.update_traces(points=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig.update_traces(points=False)\n",
"qs = pd.qcut(data_normal2, 10, labels=False)\n",
"aa = []\n",
"for ii in range(10):\n",
Expand Down Expand Up @@ -235,116 +231,9 @@
" x0=aa[ii], x1=aa[ii] + 0.02,\n",
" fillcolor=\"crimson\", opacity=0.3,\n",
" layer=\"above\", line_width=0)\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# SNR"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"colors = {'rth750':'rgba(255,8,30,1)','rthPRI':'rgba(255,117,0,1)','rthSKY':'rgba(255,220,0,1)',\n",
" 'vendor750':'rgba(0,75,255,1)','vendorPRI':'rgba(24,231,234,1)','vendorSKY':'rgba(24,234,141,1)'}\n",
"df = pd.DataFrame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df['signal'] = [1649,240,264,793,2330,2379,767,110,117,362,1023,1016]\n",
"df['noise'] = [1.68,0.34,0.33,0.66,1.64,1.65,1.66,0.32,0.34,0.6,1.72,1.71]\n",
"df['session'] = [\"rth750\",\"rthPRI\",\"rthSKY\",\"vendor750\",\"vendorPRI\",\"vendorSKY\"]*2\n",
"df['acq'] = [\"T1w\"]*6 + [\"PDw\"]*6 \n",
"df['SNR'] = 10*np.log10(df['signal']/df['noise'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"len(df)"
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig = go.Figure()\n",
"\n",
"aa = list(map(str,np.round(df['SNR'][0:6],2)))\n",
"bb = np.core.defchararray.add(['<br>']*6,df['acq'][0:6])\n",
"cc = np.core.defchararray.add(list(map(str,np.round(df['SNR'][0:6],2))), bb)\n",
"fig.add_trace(go.Bar(\n",
" y=df['SNR'][0:6],\n",
" x=df[\"session\"][0:6],\n",
" name=\"T1w\",\n",
" text=cc,\n",
" textposition='auto',\n",
" marker_color= [colors[x] for x in df['session']]))\n",
"aa = list(map(str,np.round(df['SNR'][6:12],2)))\n",
"bb = np.core.defchararray.add(['<br>']*6,df['acq'][6:12])\n",
"cc = np.core.defchararray.add(list(map(str,np.round(df['SNR'][6:12],2))), bb)\n",
"fig.add_trace(go.Bar(\n",
" y=df['SNR'][6:12],\n",
" x=df[\"session\"][6:12],\n",
" textposition='auto',\n",
" text=cc,\n",
" name=\"PDw\",\n",
" marker_color=[colors[x] for x in df['session']]))\n",
"fig.update_layout(barmode='group')\n",
"fig.update_layout(height=300, width=1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot(fig)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"aa = list(map(str,np.round(df['SNR'][0:6],2)))\n",
"bb = np.core.defchararray.add(['<br>']*6,df['acq'][0:6])\n",
"np.core.defchararray.add(list(map(str,np.round(df['SNR'][0:6],2))), bb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"['<br>']*6"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
33 changes: 25 additions & 8 deletions notebooks/phantom_python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"init_notebook_mode(connected=True)\n",
"from IPython.core.display import display, HTML\n",
"import scipy.io as sio\n",
"import random\n",
"random.seed(123)"
]
},
Expand Down Expand Up @@ -110,11 +112,14 @@
" y=df['SNR'][6:12],\n",
" x=df[\"session\"][6:12],\n",
" textposition='auto',\n",
" text=cc,\n",
" text=text,\n",
" name=\"PDw\",\n",
" marker_color=[colors[x] for x in df['session']]))\n",
"fig.update_layout(barmode='group')\n",
"fig.update_layout(height=300, width=1000)"
"fig.update_layout(height=300, width=1000)\n",
"# Needed for Lab interface (Binder)\n",
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
},
{
Expand Down Expand Up @@ -170,7 +175,8 @@
"fig.update_xaxes(axis_template,range=[0,2.1])\n",
"fig.update_yaxes(axis_template,range=[0,2.7])\n",
"fig.update_layout(title='',title_font_color=\"white\",margin=dict(l=0,r=0,t=0,b=0))\n",
"fig.update_layout(hovermode = \"x unified\")\n",
"#fig.update_layout(hovermode = \"x unified\")\n",
"fig.update_layout(hovermode = \"x\")\n",
"fig.add_trace(go.Scatter(\n",
" x=refMean, y=refMean,\n",
" line_color='black',\n",
Expand All @@ -180,7 +186,10 @@
"\n",
"))\n",
"\n",
"plot(fig)"
"#plot(fig)\n",
"# Needed for Lab interface (Binder)\n",
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
},
{
Expand Down Expand Up @@ -223,11 +232,15 @@
" )\n",
"fig.update_xaxes(axis_template,zerolinecolor=\"black\",zerolinewidth=3)\n",
"fig.update_yaxes(axis_template,zerolinecolor=\"black\")\n",
"fig.update_layout(hovermode = \"y unified\")\n",
"#fig.update_layout(hovermode = \"y unified\")\n",
"fig.update_layout(hovermode = \"y\")\n",
"fig.update_xaxes(range=[-18,70])\n",
"fig.update_yaxes(tickvals=spheres[::-1])\n",
"fig.update_layout(title_font_color=\"white\")\n",
"plot(fig)"
"#plot(fig)\n",
"# Needed for Lab interface (Binder)\n",
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
},
{
Expand Down Expand Up @@ -387,9 +400,13 @@
"\n",
"fig.update_xaxes(axis_template)\n",
"fig.update_yaxes(axis_template)\n",
"fig.update_layout(hovermode = \"x unified\")\n",
"#fig.update_layout(hovermode = \"x unified\")\n",
"fig.update_layout(hovermode = \"x\")\n",
"\n",
"fig"
"#fig\n",
"# Needed for Lab interface (Binder)\n",
"plot(fig, filename = 'fig.html')\n",
"display(HTML('fig.html'))"
]
}
],
Expand Down

0 comments on commit 5075802

Please sign in to comment.