ucl-pond / pySuStaIn

Subtype and Stage Inference (SuStaIn) algorithm with an example using simulated data.
MIT License
125 stars 64 forks source link

IndexError while running the SuStaIn Workshop file #33

Closed chinei closed 2 years ago

chinei commented 2 years ago

Before running SuStaIn using my own data, I wanted to run SuStaIn using the workshop file. Everything went smoothly except for when I want to plot the positional variance diagrams (under "Evaluate subtypes" and "choosing the optimal number of subtypes"). Python then throws the following error at me:

IndexError Traceback (most recent call last)

in 1 N_S_selected = 2 2 ----> 3 pySuStaIn.ZscoreSustain._plot_sustain_model(sustain_input,samples_sequence,samples_f,M,subtype_order=(0,1)) 4 _ = plt.suptitle('SuStaIn output') 5 ~\xxx\pySuStaIn\ZscoreSustain.py in _plot_sustain_model(self, *args, **kwargs) 450 451 def _plot_sustain_model(self, *args, **kwargs): --> 452 return ZscoreSustain.plot_positional_var(*args, Z_vals=self.Z_vals, **kwargs) 453 454 def subtype_and_stage_individuals_newData(self, data_new, samples_sequence, samples_f, N_samples): ~\xxx\pySuStaIn\notebooks\pySuStaIn\ZscoreSustain.py in plot_positional_var(samples_sequence, samples_f, n_samples, Z_vals, biomarker_labels, ml_f_EM, cval, subtype_order, biomarker_order, title_font_size, stage_font_size, stage_label, stage_rot, stage_interval, label_font_size, label_rot, cmap, biomarker_colours, figsize, separate_subtypes, save_path, save_kwargs) 622 # Shuffle vals according to subtype_order 623 # This defaults to previous method if custom order not given --> 624 vals = temp_mean_f[subtype_order] 625 626 if n_samples != np.inf: IndexError: too many indices for array Could it be that there is something wrong with the dimensions of the array? When I get rid of ",subtype_order=(0,1))" (line 3), I get at least part of the output. Same applies to when I want to plot the positional variance diagrams before crossvalidation. Any hint would be very welcome. Kind regards
sea-shunned commented 2 years ago

Hi @chinei

Thanks for raising this issue!

The problem was with numpy treating tuples differently from lists when indexing. This has been fixed, but if anything else comes up please raise another issue :)

chinei commented 2 years ago

I thought it must be a trivial thing but wow that was quick, many thanks! :)