Skip to content

Commit

Permalink
Merge pull request #81 from lyhyl/master
Browse files Browse the repository at this point in the history
fix bugs and typos. improve documentation.
  • Loading branch information
MStarmans91 committed Aug 14, 2023
2 parents ae2ef53 + 67067d4 commit 3e49286
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion WORC/doc/static/user_manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion WORC/featureprocessing/StatisticalTestFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 9 additions & 4 deletions WORC/plotting/plot_pvalues_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down

0 comments on commit 3e49286

Please sign in to comment.