Skip to content

Commit

Permalink
Declutter harmonization plot
Browse files Browse the repository at this point in the history
  • Loading branch information
melhemr committed Dec 14, 2021
1 parent b781cdf commit 0c53edc
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions QtBrainChartGUI/plugins/harmonization/harmonization.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ def plotMUSE(self,plotOptions):
parameters = pd.concat([model_parameters,self.calculated_parameters],axis=0).sort_index()
parameters = parameters[parameters.index.isin(list(cSite.keys()))]
parameters['SITE']=parameters.index
gamma_values = [str(x) for x in parameters[selected_gamma].values.round(3).tolist()]
delta_values = [str(x) for x in parameters[selected_delta].values.round(3).tolist()]
zipped = zip(['g='+x for x in gamma_values],[' d='+y for y in delta_values])
gamma_values = [x for x in parameters[selected_gamma].values.round(3).tolist()]
gamma_values = ["{:.3f}".format(x) for x in gamma_values]
delta_values = [x for x in parameters[selected_delta].values.round(3).tolist()]
delta_values = ["{:.3f}".format(x) for x in delta_values]
zipped = zip([x for x in gamma_values],[' '+y for y in delta_values])
parameter_labels = [str(m)+str(n) for m,n in zipped]
parameters.loc[:,'parameter_labels'] = parameter_labels

Expand All @@ -282,16 +284,26 @@ def plotMUSE(self,plotOptions):
lower_limit = min(parameters[selected_gamma]-parameters[selected_delta])
limit = max(abs(upper_limit),abs(lower_limit))
self.plotCanvas.axes2.set_xlim(-limit,limit)
self.plotCanvas.axes2.set_ylim(self.plotCanvas.axes1.get_ylim()[0],self.plotCanvas.axes1.get_ylim()[1]+0.1)
print(self.plotCanvas.axes2.get_ylim())
sns.set(style='white')
self.plotCanvas.axes2.errorbar(x=parameters[selected_gamma],y=parameters['SITE'],xerr=parameters[selected_delta],ecolor='black',elinewidth=0.25,capsize=1,zorder=-1,fmt='none')
b = sns.scatterplot(x=selected_gamma,y='SITE',data=parameters.reset_index(),hue='SITE',palette=cSite,marker='s',zorder=1,ax=self.plotCanvas.axes2,legend=False)
self.plotCanvas.axes2.errorbar(x=parameters[selected_gamma],y=parameters['SITE'],xerr=parameters[selected_delta],ecolor='black',elinewidth=0.25,capsize=5,zorder=-1,fmt='none')
kws = {"s": 20, "facecolor": "none", "linewidth": 1}
color = parameters[parameters[selected_gamma].notna()]['SITE'].map(cSite)
b = sns.scatterplot(x=selected_gamma,y='SITE',data=parameters.reset_index(),marker='s',edgecolor=color,**kws,zorder=1,ax=self.plotCanvas.axes2,legend=False)
for count,site in enumerate(parameters['SITE']):
self.plotCanvas.axes2.get_yticks()
b.text(-1,self.plotCanvas.axes2.get_yticks()[count]-0.2,parameters.loc[site]['parameter_labels'],fontsize=10)
if 'nan' in parameters.loc[site]['parameter_labels']:
self.plotCanvas.axes2.get_yticks()
b.text(-0.35,self.plotCanvas.axes2.get_yticks()[count]-0.3,'nan',fontsize=4)
elif '-' not in parameters.loc[site]['parameter_labels']:
self.plotCanvas.axes2.get_yticks()
b.text(-0.35,self.plotCanvas.axes2.get_yticks()[count]-0.3,' '+parameters.loc[site]['parameter_labels'],fontsize=10)
else:
self.plotCanvas.axes2.get_yticks()
b.text(-0.35,self.plotCanvas.axes2.get_yticks()[count]-0.3,parameters.loc[site]['parameter_labels'],fontsize=10)
b.set_title('Shift, Scale')
b.set_xlabel('')
b.set_ylabel('')
self.plotCanvas.axes2.set_ylim( self.plotCanvas.axes1.get_ylim() )
b.set(yticklabels=[])
self.plotCanvas.axes2.xaxis.set_ticks_position('bottom')
b.tick_params(axis='both',left=False,right=False, length=4)
Expand All @@ -300,6 +312,7 @@ def plotMUSE(self,plotOptions):

self.plotCanvas.axes3.get_figure().set_tight_layout(True)
self.plotCanvas.axes3.set_xlim(-4*sd_raw, 4*sd_raw)
self.plotCanvas.axes3.set_ylim( self.plotCanvas.axes1.get_ylim() )
sns.set(style='white')
c = sns.boxplot(x=h_res, y="SITE", data=data, palette=cSite,linewidth=0.25,showfliers = False,ax=self.plotCanvas.axes3,**PROPS)
nobs2 = data['SITE'].value_counts().sort_index(ascending=True).values
Expand Down

0 comments on commit 0c53edc

Please sign in to comment.