diff --git a/WORC/doc/static/user_manual.rst b/WORC/doc/static/user_manual.rst index 472999b0..32962d75 100644 --- a/WORC/doc/static/user_manual.rst +++ b/WORC/doc/static/user_manual.rst @@ -404,7 +404,7 @@ The following outputs and evaluation methods are always generated: 4. The extracted features. - Stored in the ``Features`` folder, in the files ``features_{featuretoolboxname}_{image_type}_{num}_{sample_id}.hdf5``. Contains a panas series wih the following attributes: + Stored in the ``Features`` folder, in the files ``features_{featuretoolboxname}_{image_type}_{num}_{sample_id}.hdf5``. Contains a pandas series with the following attributes: - feature_labels: the labels or names of the features. - feature_values: the value of the features. Each element corresponds with the same element from the feature_labels attribute. diff --git a/WORC/featureprocessing/StatisticalTestFeatures.py b/WORC/featureprocessing/StatisticalTestFeatures.py index ab53647c..7e791be8 100644 --- a/WORC/featureprocessing/StatisticalTestFeatures.py +++ b/WORC/featureprocessing/StatisticalTestFeatures.py @@ -161,7 +161,10 @@ def StatisticalTestFeatures(features, patientinfo, config, output_csv=None, # Optional: perform chi2 test. Only do this when categorical, which we define as less than 20 options. unique_values = list(set(fv)) unique_values.sort() - if len(unique_values) == 1: + if len(unique_values) == 0: # All NaN + print("[WORC Warning] " + fl + " has no value. Replacing chi2 metric value by NaN.") + pvalueschi2.append(np.nan) + elif len(unique_values) == 1: print("[WORC Warning] " + fl + " has only one value. Replacing chi2 metric value by NaN.") pvalueschi2.append(np.nan) elif len(unique_values) <= 20: diff --git a/WORC/plotting/plot_pvalues_features.py b/WORC/plotting/plot_pvalues_features.py index a00ef335..20fddf54 100644 --- a/WORC/plotting/plot_pvalues_features.py +++ b/WORC/plotting/plot_pvalues_features.py @@ -76,16 +76,21 @@ def manhattan_importance(values, labels, feature_labels, ymaxlim = i - 1 break - ymin = np.min(values) + ymin = np.min(values) # might be zero + yposmin = max(np.min(values[values > 0]), np.finfo(values.dtype).eps) for i in range(0, 100): - if 10**(-i) < ymin: + if 10**(-i) < (ymin if ymin > 0 else yposmin): yminlim = i break # Set several figure lay-out options plt.gca().invert_yaxis() - plt.yscale('log') - plt.ylim((10**-ymaxlim, 10**-yminlim)) + if ymin > 0: + plt.yscale('log') + plt.ylim((10**-ymaxlim, 10**-yminlim)) + else: + plt.yscale('symlog', linthresh=10**-yminlim) + plt.ylim((10**-ymaxlim, 0.0)) plt.xlim((0, max(positions))) plt.yticks([10**-i for i in range(ymaxlim, yminlim + 1)],