Skip to content

Commit

Permalink
Merge pull request #63 from matthias-k/enh-scanpaths
Browse files Browse the repository at this point in the history
first step of large restructuring
  • Loading branch information
matthias-k authored Apr 15, 2024
2 parents 607fa71 + a788b06 commit e86435d
Show file tree
Hide file tree
Showing 38 changed files with 4,575 additions and 3,016 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
*.c
*.so
*.egg-info
.vscode
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

* 0.3 (dev):
This is a major release, refactoring most of `pysaliency.datasets` including some breaking changes.
* Feature: `Scanpaths` is a new class for storing scanpaths. It has a similar API to the old `FixationTrains`,
but exclusively cares about scanpaths. For example, the length of a Scanpaths instance is the number of scanpaths,
not the number of fixations. It is intended to make iterating over and working with scanpaths more convenient.
* Feature: `ScanpathFixations` is a new subclass of `Fixations` intended for handling fixations that come from scanpaths.
It is intended to replace the old `FixationTrains` class. `ScanpathFixations` has a `scanpaths: Scanpaths`
attribute storing the source scanpaths (what used to be stored manually as `train_xs` etc in `FixationTrains`).
Unlike `FixationTrains`, `ScanpathFixations` does not have any attributes that are not derived from the scanpaths.
`FixationTrains` is now a deprecated subclass of `ScanpathFixations` which adds the old properties and constructor
and allows for attributes which are neither scanpath attributes nor scanpath fixation attributes.
* Feature: `VariableLengthArray` for inuititively handling data like scanpaths where each row can have a different length.
`Fixations.x_Hist`, `Fixations.y_hist`, `Scanpaths.xs` etc are now instances of `VariableLengthArray`.
* `Fixations.lengths` has been renamed to `Fixations.scanpath_history_length` to make it clear that it is the length of the scanpath history.
`Fixations.lengths` is now a deprecated alias.
* In general, naming convention for attriutes has been changed to use the plural form if the attribute is a list of values for each
element (i.e., `Scanpaths.xs`) and the singular form if the attribute is a single value (i.e., `Scanpaths.length`, `Fixations.x`). This resulted in
renaming `Fixations.subjects` to `Fixations.subject`. The old name is now a deprecated alias.

* 0.2.22:
* Enhancement: New [Tutorial](notebooks/Tutorial.ipynb).
* Bugfix: `SaliencyMapModel.AUC` failed if some images didn't have any fixations.
Expand Down
103 changes: 54 additions & 49 deletions notebooks/Tutorial.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pysaliency/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from .datasets import (
Fixations,
FixationTrains,
ScanpathFixations,
Scanpaths,
Stimuli,
FileStimuli,
create_nonfixations,
Expand Down
6 changes: 3 additions & 3 deletions pysaliency/baseline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numba
import numpy as np
from boltons.iterutils import chunked
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import gaussian_filter
from scipy.special import logsumexp
from sklearn.base import BaseEstimator, DensityMixin
from sklearn.model_selection import cross_val_score
Expand Down Expand Up @@ -137,7 +137,7 @@ def __iter__(self):
for n in range(len(self.stimuli)):
for s in range(self.fixations.subject_count):
image_inds = self.fixations.n == n
subject_inds = self.fixations.subjects == s
subject_inds = self.fixations.subject == s
train_inds, test_inds = image_inds & ~subject_inds, image_inds & subject_inds
if test_inds.sum() == 0 or train_inds.sum() == 0:
#print("Skipping")
Expand All @@ -152,7 +152,7 @@ def __iter__(self):
yield train_inds, test_inds

def __len__(self):
return len(set(zip(self.fixations.n, self.fixations.subjects)))
return len(set(zip(self.fixations.n, self.fixations.subject)))


class ScikitLearnWithinImageCrossValidationGenerator(object):
Expand Down
Loading

0 comments on commit e86435d

Please sign in to comment.