88import matplotlib .pyplot as plt
99import numpy as np
1010import pandas as pd
11+ from niCHART .plugins .loadsave .dataio import DataIO
1112from niCHART .core .plotcanvas import PlotCanvas
1213from niCHART .core .gui .SearchableQComboBox import SearchableQComboBox
1314
@@ -33,13 +34,24 @@ def getUI(self):
3334
3435 def SetupConnections (self ):
3536 self .datamodel .data_changed .connect (lambda : self .OnDataChanged ())
37+ self .datamodel .model_changed .connect (lambda : self .OnModelChanged ())
3638 self .ui .comboBoxROI .currentIndexChanged .connect (self .UpdatePlot )
3739 self .ui .comboBoxHue .currentIndexChanged .connect (self .UpdatePlot )
3840
3941 def OnDataChanged (self ):
4042 self .PopulateROI ()
4143 self .PopulateHue ()
4244
45+ def OnModelChanged (self ):
46+ self .GetMUSEROIDict ()
47+ self .PopulateROI ()
48+
49+ def GetMUSEROIDict (self ):
50+ dio = DataIO ()
51+ #also read MUSE dictionary
52+ MUSEDictNAMEtoID , MUSEDictIDtoNAME , MUSEDictDataFrame = dio .ReadMUSEDictionary ()
53+ self .datamodel .SetMUSEDictionaries (MUSEDictNAMEtoID , MUSEDictIDtoNAME ,MUSEDictDataFrame )
54+
4355 def PopulateROI (self ):
4456 #get data column header names
4557 datakeys = self .datamodel .GetColumnHeaderNames ()
@@ -58,7 +70,6 @@ def PopulateROI(self):
5870 if invalid_ROI in roiList :
5971 roiList .remove (invalid_ROI )
6072
61-
6273 _ , MUSEDictIDtoNAME = self .datamodel .GetMUSEDictionaries ()
6374 roiList = list (set (roiList ).intersection (set (datakeys )))
6475 roiList .sort ()
@@ -131,16 +142,16 @@ def PlotAgeTrends(self,plotOptions):
131142 self .plotCanvas .axes .clear ()
132143
133144 # seaborn plot on axis
134- a = sns . scatterplot ( x = 'Age' , y = currentROI , hue = currentHue , ax = self .plotCanvas . axes , s = 5 ,
135- data = self . datamodel . GetData ( currentROI ,currentHue ))
136- self .plotCanvas . axes . yaxis . set_ticks_position ( 'left' )
137- self .plotCanvas .axes .xaxis .set_ticks_position ('bottom ' )
138- sns . despine ( fig = self .plotCanvas .axes .get_figure (), trim = True )
139- self .plotCanvas .axes .get_figure (). set_tight_layout ( True )
140-
141- # Plot normative range if according GAM model is available
142- if (self .datamodel .harmonization_model is not None ) and (currentROI in ['H_' + x for x in self .datamodel .harmonization_model ['ROIs' ]]):
143- x ,y ,z = self .datamodel .GetNormativeRange (currentROI [ 2 :] )
145+ if self .datamodel . data is not None :
146+ a = sns . scatterplot ( x = 'Age' , y = currentROI , hue = currentHue , ax = self . plotCanvas . axes , s = 5 ,
147+ data = self .datamodel . GetData ( currentROI , currentHue ) )
148+ self .plotCanvas .axes .yaxis .set_ticks_position ('left ' )
149+ self .plotCanvas .axes .xaxis . set_ticks_position ( 'bottom' )
150+ sns . despine ( fig = self .plotCanvas .axes .get_figure (), trim = True )
151+ self . plotCanvas . axes . get_figure (). set_tight_layout ( True )
152+
153+ if (self .datamodel .harmonization_model is not None ) and (currentROI in [x for x in self .datamodel .harmonization_model ['ROIs' ]]):
154+ x ,y ,z = self .datamodel .GetNormativeRange (currentROI )
144155 #print('Pooled variance: %f' % (z))
145156 # Plot three lines as expected mean and +/- 2 times standard deviation
146157 sns .lineplot (x = x , y = y , ax = self .plotCanvas .axes , linestyle = '-' , markers = False , color = 'k' )
0 commit comments