Skip to content

Commit dbb0302

Browse files
Merge pull request #109 from paxtonfitzpatrick/master
updated examples
2 parents f561ac9 + 5f04f69 commit dbb0302

15 files changed

+847
-815
lines changed

docs/tutorial/.ipynb_checkpoints/naturalistic-analyses-checkpoint.ipynb

Lines changed: 374 additions & 383 deletions
Large diffs are not rendered by default.

docs/tutorial/naturalistic-analyses.ipynb

Lines changed: 374 additions & 383 deletions
Large diffs are not rendered by default.

examples/crack_egg.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,6 @@
1818
egg = quail.load('example')
1919

2020
#crack egg
21-
cracked_egg = quail.crack_egg(egg, subjects=[0], lists=[0])
21+
cracked_egg = egg.crack(subjects=[0], lists=[0])
2222

2323
cracked_egg.info()
24-
25-
pres = cracked_egg.get_pres_items().as_matrix()[0]
26-
rec = cracked_egg.get_rec_items().as_matrix()[0]
27-
28-
def distmat(egg, feature, distdict):
29-
f = [xi[feature] for xi in egg.get_pres_features()]
30-
return cdist(f, f, distdict[feature])
31-
32-
33-
for idx in range(len(rec)-1):
34-
ind1 = np.where(pres==rec[idx])[0][0]
35-
ind2 = np.where(pres==rec[idx+1])[0][0]
36-
dists = dist[ind1, :]
37-
cdist = dist[ind1, ind2]
38-
rank = np.mean(np.where(np.sort(dists)[::-1] == cdist))

examples/create_egg.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,40 +17,69 @@
1717

1818

1919
# generate some fake data
20-
next_presented = ['CAT', 'DOG', 'SHOE', 'HORSE']
21-
next_recalled = ['HORSE', 'DOG', 'CAT']
22-
23-
next_features = [{
20+
presented = [{
21+
'item' : 'CAT',
2422
'category' : 'animal',
2523
'size' : 'bigger',
2624
'starting letter' : 'C',
2725
'length' : 3
2826
},
2927
{
28+
'item' : 'DOG',
3029
'category' : 'animal',
3130
'size' : 'bigger',
3231
'starting letter' : 'D',
3332
'length' : 3
3433
},
3534
{
35+
'item' : 'SHOE',
3636
'category' : 'object',
3737
'size' : 'smaller',
3838
'starting letter' : 'S',
3939
'length' : 4
4040
},
4141
{
42+
'item' : 'HORSE',
4243
'category' : 'animal',
4344
'size' : 'bigger',
4445
'starting letter' : 'H',
4546
'length' : 5
4647
}
4748
]
49+
50+
recalled = [{
51+
'item' : 'HORSE',
52+
'category' : 'animal',
53+
'size' : 'bigger',
54+
'starting letter' : 'H',
55+
'length' : 5
56+
},
57+
{
58+
'item' : 'DOG',
59+
'category' : 'animal',
60+
'size' : 'bigger',
61+
'starting letter' : 'D',
62+
'length' : 3
63+
},
64+
{
65+
'item' : 'CAT',
66+
'category' : 'animal',
67+
'size' : 'bigger',
68+
'starting letter' : 'C',
69+
'length' : 3
70+
}
71+
]
72+
73+
# set some custom distance functions
4874
dist_funcs = {
4975
'category' : 'lambda a, b: int(a!=b)',
5076
'size' : 'lambda a, b: int(a!=b)',
5177
'starting letter' : 'lambda a, b: int(a!=b)',
5278
'length' : 'lambda a, b: np.linalg.norm(np.subtract(a,b))'
5379
}
54-
egg = quail.Egg(pres=[next_presented], rec=[next_recalled], features=[next_features], dist_funcs=dist_funcs)
5580

56-
egg.analyze('lagcrp').plot()
81+
egg = quail.Egg(pres=[presented], rec=[recalled], dist_funcs=dist_funcs)
82+
83+
fegg = egg.analyze('lagcrp')
84+
85+
fegg.plot()

examples/create_multisubject_egg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@
2626
egg = quail.Egg(pres=presented_words, rec=recalled_words)
2727

2828
# analyze and plot
29-
egg.analyze('accuracy').plot(plot_style='violin', title='Average Recall Accuracy')
29+
fegg = egg.analyze('accuracy')
30+
31+
fegg.plot(plot_style='violin', title='Average Recall Accuracy')

examples/decode_speech.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# decode speech
1818
recall_data = quail.decode_speech('../data/sample.wav', save=True,
1919
speech_context=['DONKEY', 'PETUNIA'],
20-
keypath='/Users/andyheusser/Documents/cdl/credentials/efficient-learning-553bf474f805.json')
20+
keypath='path/to/key.json')
2121

2222
# print results
2323
print(recall_data)

examples/fingerprint_optimalpresenter.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,66 @@
1616
from quail import Fingerprint, OptimalPresenter
1717

1818
# generate some fake data
19-
next_presented = ['CAT', 'DOG', 'SHOE', 'BAT']
20-
next_recalled = ['DOG', 'CAT', 'BAT', 'SHOE']
21-
22-
next_features = [{
19+
next_presented = [{
20+
'item' : 'CAT',
2321
'category' : 'animal',
2422
'size' : 'bigger',
2523
'starting letter' : 'C',
2624
'length' : 3
2725
},
2826
{
27+
'item' : 'DOG',
2928
'category' : 'animal',
3029
'size' : 'bigger',
3130
'starting letter' : 'D',
3231
'length' : 3
3332
},
3433
{
34+
'item' : 'SHOE',
3535
'category' : 'object',
3636
'size' : 'smaller',
3737
'starting letter' : 'S',
3838
'length' : 4
3939
},
4040
{
41+
'item' : 'BAT',
4142
'category' : 'animal',
4243
'size' : 'bigger',
4344
'starting letter' : 'B',
4445
'length' : 3
4546
}]
4647

47-
egg = quail.Egg(pres=[next_presented], rec=[next_recalled], features=[next_features])
48+
next_recalled = [{
49+
'item' : 'DOG',
50+
'category' : 'animal',
51+
'size' : 'bigger',
52+
'starting letter' : 'D',
53+
'length' : 3
54+
},
55+
{
56+
'item' : 'CAT',
57+
'category' : 'animal',
58+
'size' : 'bigger',
59+
'starting letter' : 'C',
60+
'length' : 3
61+
},
62+
{
63+
'item' : 'BAT',
64+
'category' : 'animal',
65+
'size' : 'bigger',
66+
'starting letter' : 'B',
67+
'length' : 3
68+
},
69+
{
70+
'item' : 'SHOE',
71+
'category' : 'object',
72+
'size' : 'smaller',
73+
'starting letter' : 'S',
74+
'length' : 4
75+
}
76+
]
77+
78+
egg = quail.Egg(pres=[next_presented], rec=[next_recalled])
4879

4980
# initialize fingerprint
5081
fingerprint = Fingerprint(init=egg)

examples/plot_fingerprint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
egg = quail.load('example')
2424

2525
# analyze and plot
26-
egg.analyze('fingerprint', listgroup=['average']*8, features=['temporal']).plot(title='Memory Fingerprint')
26+
fegg = egg.analyze('fingerprint', listgroup=['average']*8, features=['temporal'])
27+
28+
fegg.plot(title='Memory Fingerprint')

examples/plot_lagcrp.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
egg = quail.load('example')
2121

2222
# analyze and plot
23-
egg.analyze('lagcrp', listgroup=['average']*8).plot(title='Lag-CRP')
23+
fegg = egg.analyze('lagcrp', listgroup=['average']*8)
24+
25+
fegg.plot(title='Lag-CRP')

examples/plot_pfr.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
import quail
1717

1818
#load data
19-
egg = quail.load_example_data()
19+
egg = quail.load('example')
2020

21-
# analysis
22-
analyzed_data = quail.analyze(egg, analysis='pfr', listgroup=['average']*8)
21+
# analyze and plot
22+
fegg = egg.analyze('pfr', listgroup=['average']*8)
2323

24-
# plot
25-
quail.plot(analyzed_data, title='Probability of First Recall')
24+
fegg.plot(title='Probability of First Recall')

examples/plot_pnr.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
import quail
1717

1818
#load data
19-
egg = quail.load_example_data()
19+
egg = quail.load('example')
2020

21-
# analysis
22-
analyzed_data = quail.analyze(egg, analysis='pnr', listgroup=['average']*8,
21+
# analyze and plot
22+
fegg = egg.analyze('pnr', listgroup=['average']*8,
2323
position=5)
2424

25-
# plot
26-
quail.plot(analyzed_data, title='Probability of Recall')
25+
fegg.plot(title='Probability of Recall')

examples/plot_spc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import quail
1717

1818
#load data
19-
egg = quail.load_example_data()
19+
egg = quail.load('example')
2020

2121
# analyze and plot
22-
egg.analyze('spc', listgroup=['average']*8).plot(title='Serial Position Curve')
22+
fegg = egg.analyze('spc', listgroup=['average']*8)
23+
24+
fegg.plot(title='Serial Position Curve')

examples/plot_temporal.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
import quail
1717

1818
#load data
19-
egg = quail.load_example_data()
19+
egg = quail.load('example')
2020

21-
#analysis
22-
analyzed_data = quail.analyze(egg, analysis='temporal', listgroup=['early']*4+['late']*4)
21+
#analyze and plot
22+
fegg = egg.analyze('temporal', listgroup=['early']*4+['late']*4)
2323

24-
#plot
25-
quail.plot(analyzed_data, title='Temporal Clustering')
24+
fegg.plot(title='Temporal Clustering')

quail/data/naturalistic.egg

608 Bytes
Binary file not shown.

quail/fingerprint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def update(self, egg, permute=False, nperms=1000,
103103
pass_features=True,
104104
permute=permute,
105105
n_perms=nperms,
106-
parallel=parallel).as_matrix(), 0)
106+
parallel=parallel).values, 0)
107107

108108
if self.state is not None:
109109

0 commit comments

Comments
 (0)