Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first step of large restructuring #63

Merged
merged 31 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dbb7edf
Feature: VariableLengthArray for scanpath coordinates, histories etc
matthias-k Mar 27, 2024
feaa9fd
Python 3.8 compatibility
matthias-k Mar 27, 2024
4531a03
Typo in tutorial
matthias-k Mar 27, 2024
f7e8064
Scanpaths class, first version
matthias-k Mar 27, 2024
10d77ed
VariableLengthArray.copy
matthias-k Mar 28, 2024
de43b3a
Concatenate variable length arrays
matthias-k Mar 28, 2024
e6a62b3
Cleanup tutorial notebook
matthias-k Mar 28, 2024
5e4161a
Fix: VariableLengthArray failed for zero length
matthias-k Mar 28, 2024
91a3732
Bugfix
matthias-k Mar 28, 2024
305e8bf
repr for VariableLengthArray
matthias-k Mar 28, 2024
bd6cf5f
Adapt FixationTrain attributes
matthias-k Mar 29, 2024
7f3427d
upgrade FixationTrains.train_xs etc to VariableLengthArrays
matthias-k Mar 29, 2024
90cd701
Bugfix
matthias-k Mar 31, 2024
42c9ecf
Enh! Rename scanpaths.ns to scanpaths.n because it's only one value p…
matthias-k Apr 1, 2024
9d02104
refactor methods to use FixationTrains.scanpaths where applicable
matthias-k Apr 2, 2024
f268108
Chore: Refactoring datasets.py step 1 - stimuli in own file
matthias-k Apr 2, 2024
30f78a3
Chore: Refactoring datasets.py step 1a - stimuli tests in own file
matthias-k Apr 2, 2024
79e349c
Chore: Refactoring datasets.py step 2 - fixations and scanpaths in ow…
matthias-k Apr 2, 2024
078544d
Chore: Refactoring datasets.py step 2a - fixations tests in own file
matthias-k Apr 2, 2024
4e4b497
Chore: Renaming tests where appropriate to keep term scanpaths for ac…
matthias-k Apr 2, 2024
566c11f
Chore: Refactoring tests a bit more
matthias-k Apr 2, 2024
8955b43
Copy and concatenate scanpaths
matthias-k Apr 9, 2024
369a883
ScanpathFixations: cleaned up version of FixationTrains (part 1)
matthias-k Apr 9, 2024
07fa383
Allow keyword specification of scanpath attributes
matthias-k Apr 9, 2024
2fd7c7f
typo
matthias-k Apr 9, 2024
8370517
HDF5 models should fail gracefully if file doesn't exist
matthias-k Apr 9, 2024
58af33c
Rename subjects to subject, lengths to fixation_history_length, some …
matthias-k Apr 10, 2024
cbb48fa
Adapt most code to use ScanpathFixations instead of FixationTrains
matthias-k Apr 11, 2024
01e8048
Bugfix
matthias-k Apr 11, 2024
66326ec
Missing test file
matthias-k Apr 11, 2024
a788b06
Remove failing pickle test for obsolete class, add test for new class
matthias-k Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading