Notes on setting up MongoDB to act as a place for us to store processed features.

Will be using to do this PyMongo and a MongoDB instance on mongolab to do this. Hopefully, these notes should be enough for everyone else to get the hang of it as well.

We might have problems with the space available on mongolab for our purposes. In that case, everyone might have to have a database running locally or we could have one running in the forum and instances running in other locations synced through Google Drive.

Have installed the package python-pymongo 2.7.2-1 from the official Arch Linux repos.

mongolab setup

Created an account called Neuroglycerin and a deployment database on there called features.

Connecting via PyMongo

I will have to create users for everyone that wants access to this sandbox database. Created myself a user and am connecting to it as a client below.


In [1]:
import pymongo

In [38]:
# reading in my user name and password from file so you can't read it
with open("/home/gavin/.neuromongo.user") as f:
    details = f.readlines()
# little list comprehension to strip out \ns
details = [x.strip("\n") for x in details]

In [39]:
# define a client instance
client = pymongo.MongoClient('mongodb://{0}:{1}@ds063859.mongolab.com:63859/features'.format(*details))

Instantiating the database

Instance the database as a python object:


In [46]:
db = client['features']

Making a collection

Then, have to make a collection in the database. For reference, we are now at Deployment -> Database -> Collection.

For us, it looks like the obvious choice for a collection is the name of each subject.


In [47]:
collection = db['Dog_1']

Adding stuff

So, the structure I wanted from the database, from the email, was:

As I can only think in Python, this is how it should be constructed(dictionaries are {}):

{subject_key:{feature_tag:{description:"string description", feature_data:data, ...}, ...}, ...}

But, the collection of features doesn't act like a dictionary, it appears to be more like a list. So, the structure becomes:

{subject_key:[name:"feature name", description:"string description", feature_data:data, ...], ...}

So, I'll build that structure and put in a dummy feature.


In [48]:
import numpy as np

First, actually, I'll have to define how the processed feature data should be structured to take into account mapping from the segment files:

"data":{"preictal/interictal/test":{"1":[value, ...], ...}, ...}

Note that inside the preictal/interictal/test dictionary the data is indexed by an integer, but that this has to be formatted to a string for the database to operate (which is annoying).


In [49]:
preictal,interictal,test = {},{},{}
# filling dummy data
for i in range(1,600):
    si = str(i)
    if i <= 480:
        interictal[si] = [np.random.rand()]
    if i <= 24:
        preictal[si] = [np.random.rand()]
    if i <= 502:
        test[si] = [np.random.rand()]

In [50]:
data =  {"preictal":preictal,"interictal":interictal,"test":test}

In [57]:
dummy = {"name":"dummy", "description":"A useless dummy feature.", "data":data}

In [78]:
# then we just insert this into our Dog_1 collection
dummy_id = collection.insert(dummy)

In [77]:
dummy = {"name":"the dummy feature", "description":"A useless dummy feature.", "data":data}

In [78]:
# then we just insert this into our Dog_1 collection
dummy_id = collection.insert(dummy)

And that's it, it's online, I can see it in the web dashboard and everything. Can even list the collection here:


In [60]:
db.collection_names()


Out[60]:
['system.indexes', 'system.users', 'Dog_1']

Indexing/finding

Can find a specific named feature by knowing its name:


In [68]:
collection.find_one({"name":"dummy"})


Out[68]:
{'_id': ObjectId('542883972a0c4e0963a26ad9'),
 'name': 'dummy',
 'data': {'test': {'186': [0.3964093126393088],
   '90': [0.17411617316575023],
   '404': [0.4021487956853981],
   '248': [0.272842974247159],
   '51': [0.5668333475512668],
   '8': [0.28836545146591364],
   '436': [0.6854596383178051],
   '193': [0.20350404781651754],
   '309': [0.3578421670385993],
   '449': [0.05048709631884274],
   '101': [0.615197809513281],
   '476': [0.9120898946434508],
   '286': [0.35684598634415965],
   '452': [0.6752712659522435],
   '219': [0.3931681698037971],
   '447': [0.3434770686694927],
   '171': [0.30345385384632495],
   '487': [0.044741523949826334],
   '337': [0.15560805655151133],
   '217': [0.05507590194882328],
   '223': [0.46122151829491076],
   '78': [0.7772120714265633],
   '408': [0.032077213637447644],
   '376': [0.6301027471204163],
   '68': [0.3393742586387014],
   '282': [0.15610817115214448],
   '4': [0.29260925253399617],
   '35': [0.5025315117704248],
   '50': [0.887329226223524],
   '402': [0.6158635335784178],
   '361': [0.5305009875768243],
   '413': [0.6130616012701299],
   '179': [0.905242773850216],
   '152': [0.4382111903440363],
   '394': [0.24459659272810397],
   '241': [0.22630245305049757],
   '371': [0.00020633172973438807],
   '251': [0.969786333413625],
   '106': [0.9753558068892899],
   '340': [0.030929164492115913],
   '59': [0.44868016287142687],
   '23': [0.260470861524115],
   '169': [0.13697575513335702],
   '194': [0.9617623039761689],
   '274': [0.49775262617424465],
   '74': [0.41429158062224236],
   '73': [0.11252018503663053],
   '33': [0.31449084081155676],
   '444': [0.3360744919124746],
   '272': [0.9041140189951664],
   '201': [0.25807882985370867],
   '373': [0.6750919426229064],
   '63': [0.054795960543961963],
   '357': [0.5806708459266615],
   '273': [0.33047179249948366],
   '94': [0.48386458243022445],
   '39': [0.8322714343726492],
   '12': [0.1374922074530599],
   '123': [0.007867293584129298],
   '127': [0.7438144328926117],
   '228': [0.7758418384413478],
   '301': [0.9587809105239722],
   '56': [0.8473518752364223],
   '425': [0.5415296033044451],
   '209': [0.1631763831652655],
   '52': [0.5601095976767704],
   '47': [0.6818148635210917],
   '362': [0.7324726043872684],
   '318': [0.4189146029680615],
   '5': [0.5812238609668268],
   '264': [0.030923302440085676],
   '352': [0.9768989179232914],
   '183': [0.3425483485296795],
   '423': [0.7333605220864808],
   '143': [0.3429539993627483],
   '7': [0.36527447532137636],
   '48': [0.2736768247617998],
   '351': [0.8644637345288592],
   '37': [0.7223528327542577],
   '140': [0.4541226654906937],
   '280': [0.9727893051798882],
   '9': [0.8769136324180152],
   '165': [0.3162237724653193],
   '246': [0.21598185148147553],
   '238': [0.0015892613510054554],
   '295': [0.6648168070748521],
   '195': [0.5327242570699646],
   '364': [0.2416608314262546],
   '500': [0.9993625877204054],
   '69': [0.036721691299680836],
   '136': [0.6702553081132366],
   '310': [0.8895959861789312],
   '334': [0.48269151124066434],
   '57': [0.8610960751775485],
   '46': [0.16859440065616105],
   '212': [0.4355921277304001],
   '197': [0.6072967364993361],
   '299': [0.8853072442201354],
   '121': [0.17684769468611183],
   '369': [0.7781777958517135],
   '133': [0.44461792526973176],
   '156': [0.0684309711697283],
   '126': [0.36822967568913534],
   '42': [0.2280850346252734],
   '388': [0.9973226306624955],
   '216': [0.2284014769262277],
   '26': [0.30713599127579894],
   '489': [0.8968553285600094],
   '467': [0.31400558121178235],
   '308': [0.10556586983605865],
   '422': [0.5934498754835258],
   '93': [0.922387665177306],
   '463': [0.34135227962732373],
   '27': [0.964304500534085],
   '97': [0.22209041020621367],
   '258': [0.2579714362994182],
   '315': [0.4555599063332353],
   '296': [0.45685333043129317],
   '419': [0.3131384138213281],
   '148': [0.058731508164635904],
   '485': [0.6389262579859941],
   '418': [0.8656842264370205],
   '401': [0.5575971503827175],
   '288': [0.9333249744918806],
   '257': [0.24011432224774087],
   '2': [0.7206263634616468],
   '153': [0.7416272487255103],
   '49': [0.17392872399727066],
   '384': [0.42194461841540953],
   '368': [0.02810232971553628],
   '349': [0.27435257627112397],
   '269': [0.4818891073803412],
   '114': [0.2421544494315646],
   '355': [0.8132335920673385],
   '335': [0.7252962065401736],
   '10': [0.8646973647972416],
   '85': [0.44568912279001127],
   '277': [0.048681370451860606],
   '166': [0.6693806984286212],
   '382': [0.619979533135722],
   '433': [0.6772090149614973],
   '125': [0.3984667077501478],
   '460': [0.8728112200430245],
   '95': [0.9523743215867819],
   '435': [0.7010419551305356],
   '173': [0.7082502932859165],
   '70': [0.29851843933967614],
   '72': [0.8916101778849403],
   '75': [0.4634244628991313],
   '375': [0.8451366431281493],
   '162': [0.6967534340333524],
   '324': [0.6207052673609728],
   '367': [0.9394962268816313],
   '441': [0.9113220599620547],
   '290': [0.7602267602288735],
   '431': [0.05339741984352964],
   '472': [0.7979833838254767],
   '203': [0.023178729858375102],
   '456': [0.47751306893399115],
   '88': [0.09983362346704805],
   '393': [0.9469529668777839],
   '254': [0.5003584083024852],
   '112': [0.6762263797538571],
   '191': [0.31160782085438976],
   '270': [0.6038799678891192],
   '115': [0.27621918928667455],
   '185': [0.5307401359172145],
   '477': [0.8820027486454983],
   '71': [0.10869818639475004],
   '28': [0.7259871043097409],
   '178': [0.06371575748896208],
   '104': [0.07178845495999875],
   '190': [0.03606324778096459],
   '385': [0.8303556792907605],
   '284': [0.874672508820927],
   '502': [0.24346810380581208],
   '134': [0.8584190717458599],
   '372': [0.5009796447736524],
   '329': [0.06608601076571397],
   '304': [0.11782925738585681],
   '65': [0.5715929878786337],
   '211': [0.22318736586502375],
   '442': [0.5883192142470373],
   '54': [0.13683427413282467],
   '271': [0.6511827065798785],
   '378': [0.7388989680012571],
   '356': [0.959755477713008],
   '421': [0.8161593092762188],
   '129': [0.4759618069672924],
   '256': [0.21572441456000702],
   '374': [0.799912766918237],
   '66': [0.7784537689915992],
   '249': [0.6774342816169255],
   '3': [0.7698941526770234],
   '239': [0.24466940152941485],
   '276': [0.2465059967978862],
   '398': [0.523989027840866],
   '455': [0.4095733712993245],
   '474': [0.5341313273739567],
   '314': [0.8265366238927346],
   '107': [0.03263120670162034],
   '218': [0.6368335810902357],
   '389': [0.28820504574702477],
   '236': [0.305538500500239],
   '180': [0.2624235989678113],
   '17': [0.057757664104305495],
   '454': [0.8943506406715539],
   '132': [0.5858209295883237],
   '222': [0.9957098856198003],
   '481': [0.27034949817911835],
   '158': [0.12206775950407012],
   '31': [0.8825579459689544],
   '55': [0.451707871362644],
   '325': [0.7476495877213027],
   '319': [0.6562273952445482],
   '200': [0.817325625018548],
   '380': [0.06749432381069287],
   '261': [0.9024617349200544],
   '29': [0.2851502325474894],
   '289': [0.8370367359297579],
   '192': [0.16586987398499398],
   '87': [0.5512954177760105],
   '262': [0.5750861489688778],
   '339': [0.7894879364406082],
   '32': [0.4978741753282099],
   '40': [0.6123892930252798],
   '307': [0.22424286566014273],
   '451': [0.7835208244348613],
   '287': [0.9034498818901602],
   '316': [0.9751342469200172],
   '149': [0.4168461335173558],
   '323': [0.5496370064836356],
   '188': [0.9010422050994659],
   '291': [0.0316749326006871],
   '298': [0.9257394480269784],
   '326': [0.9640158005337186],
   '347': [0.4896127575789807],
   '255': [0.5603935131403082],
   '116': [0.22529387307381032],
   '250': [0.9659831551555911],
   '207': [0.9940849105816053],
   '336': [0.20751589292404027],
   '16': [0.37678408623789916],
   '381': [0.21703342937437353],
   '224': [0.2675577167565949],
   '332': [0.4879846500509363],
   '412': [0.247292178748595],
   '213': [0.28020735439370514],
   '475': [0.84377544363746],
   '60': [0.4759527219300542],
   '163': [0.9022540059432927],
   '497': [0.38322441417073105],
   '231': [0.3991935109618848],
   '20': [0.038010133557610515],
   '208': [0.7132177048267782],
   '232': [0.8726035440036699],
   '34': [0.9736744518147076],
   '386': [0.9709795730623781],
   '268': [0.21955064713371275],
   '266': [0.5504384271292017],
   '471': [0.3160880157676421],
   '214': [0.42277481126663397],
   '182': [0.08943216468750348],
   '135': [0.7837140225350134],
   '204': [0.400223634503895],
   '131': [0.824862782050019],
   '406': [0.8585351078658167],
   '142': [0.1800062144553891],
   '466': [0.6155096911011879],
   '172': [0.04439653403536159],
   '390': [0.08957159561142336],
   '252': [0.6364202525181905],
   '450': [0.21852258774635247],
   '245': [0.26404533520640805],
   '328': [0.16345059754568814],
   '221': [0.7092882183348216],
   '21': [0.8704320422165317],
   '86': [0.8209980070484107],
   '30': [0.745113644838359],
   '453': [0.49099648228815684],
   '415': [0.3357452314580609],
   '247': [0.6105877297053371],
   '501': [0.9027524432704209],
   '438': [0.44973331082712387],
   '392': [0.19612207486172717],
   '53': [0.40205684828223576],
   '233': [0.6436454648711842],
   '128': [0.04680085251096955],
   '358': [0.4033635657991025],
   '488': [0.24568209796026041],
   '443': [0.015454139795050725],
   '64': [0.567960526068274],
   '36': [0.6530691527546101],
   '300': [0.9792302649368738],
   '294': [0.7360411228688607],
   '396': [0.2440762498268968],
   '244': [0.6274525133358184],
   '383': [0.19436488961643283],
   '138': [0.8181794689463594],
   '405': [0.8785825457749293],
   '189': [0.39889563223229907],
   '77': [0.3540878634566259],
   '43': [0.13224579199482234],
   '102': [0.8520579694704148],
   '113': [0.8421364522267507],
   '167': [0.15330285024242718],
   '174': [0.74100578933968],
   '22': [0.4065728231416673],
   '105': [0.7150776901156765],
   '76': [0.02359356275563229],
   '109': [0.11803402649978456],
   '160': [0.9137894893015378],
   '344': [0.42798392574324984],
   '410': [0.7402645225336577],
   '150': [0.8562176783036898],
   '176': [0.6823922180879033],
   '157': [0.826592351375417],
   '62': [0.21010987655151836],
   '155': [0.8406761964404829],
   '14': [0.39051826168409576],
   '124': [0.6329184683283323],
   '205': [0.8945011351839067],
   '6': [0.2486376691275558],
   '397': [0.8873430531232243],
   '303': [0.47553190565557346],
   '479': [0.23487036064520994],
   '391': [0.8223006837588561],
   '360': [0.05450340352643279],
   '317': [0.5080501710995484],
   '321': [0.8229269160355667],
   '108': [0.977646560751247],
   '110': [0.6876514870306135],
   '430': [0.3189926546535291],
   '61': [0.46832410802518154],
   '283': [0.6844707929230435],
   '92': [0.8701038565176034],
   '175': [0.3996392883005887],
   '229': [0.07110394374606654],
   '293': [0.7649781161685698],
   '161': [0.9412036044043225],
   '400': [0.6349743624564761],
   '240': [0.06262132715207924],
   '491': [0.6350328922308858],
   '366': [0.7988291122498319],
   '387': [0.4813028510023015],
   '278': [0.07898786338854158],
   '118': [0.11602101393477793],
   '292': [0.12175324885194116],
   '445': [0.7400041039468371],
   '11': [0.5917779620350628],
   '230': [0.5410179488172245],
   '495': [0.8109299240323031],
   '184': [0.4522588026787461],
   '263': [0.2933180701350727],
   '80': [0.3709178875531358],
   '41': [0.3007774312701105],
   '338': [0.9703900906838874],
   '159': [0.11799885373096242],
   '146': [0.7850736815075855],
   '424': [0.892038630594606],
   '243': [0.27316843332200413],
   '227': [0.28646843049094384],
   '417': [0.17676233687453513],
   '439': [0.15574639667555368],
   '44': [0.10938569861498515],
   '469': [0.6183900767853734],
   '206': [0.14277158252035405],
   '187': [0.6944794462542668],
   '446': [0.2583168666311849],
   '237': [0.26852030225382717],
   '83': [0.34969083656881406],
   '468': [0.16820394356518686],
   '122': [0.8809425010146955],
   '285': [0.3600591528142766],
   '353': [0.49874954767388946],
   '220': [0.37352349590406064],
   '13': [0.5535753779118677],
   '432': [0.8159411104460265],
   '99': [0.6085320337834768],
   '58': [0.28978678499241217],
   '305': [0.13612003086292135],
   '399': [0.31454615170222155],
   '482': [0.7538480593238106],
   '103': [0.06869516307506607],
   '260': [0.44836360752780546],
   '320': [0.5701340910684195],
   '130': [0.9895061607963729],
   '363': [0.807015357716067],
   '414': [0.19164285878707588],
   '473': [0.273051514631527],
   '403': [0.4692792103929492],
   '496': [0.6735632231259305],
   '429': [0.3023529967834033],
   '462': [0.20366600725494322],
   '242': [0.29211372378170297],
   '154': [0.35188276595983303],
   '79': [0.33393559123137007],
   '145': [0.2815283610090388],
   '144': [0.8391334432076069],
   '210': [0.23081365370067064],
   '234': [0.9919129709163858],
   '457': [0.4268861999959199],
   '111': [0.12399896216705086],
   '470': [0.027082817380137958],
   '151': [0.8862889097336722],
   '313': [0.8490224528667527],
   '407': [0.1611832275535231],
   '265': [0.13982726451423533],
   '459': [0.8609686392770961],
   '377': [0.888728070554297],
   '226': [0.4454889972051349],
   '327': [0.7473269167072596],
   '199': [0.7530942000613999],
   '25': [0.46379995950891273],
   '480': [0.34743907895708714],
   '311': [0.000602356932892012],
   '225': [0.3970686666344301],
   '117': [0.13840388377599533],
   '120': [0.607226807046164],
   '100': [0.24741459778753994],
   '395': [0.9077761384319837],
   '483': [0.8857218363358044],
   '198': [0.31962761931695416],
   '330': [0.755674205818094],
   '427': [0.8727978003719914],
   '434': [0.3968212367169701],
   '259': [0.5356193154013048],
   '440': [0.43375266019915326],
   '164': [0.9805310887553393],
   '458': [0.1336216050558513],
   '486': [0.04434669716616724],
   '89': [0.12729823330600754],
   '170': [0.5353935104306756],
   '177': [0.6896322285548019],
   '18': [0.7932568244785263],
   '202': [0.21822229172251173],
   '275': [0.3537523302856447],
   '297': [0.94082017565577],
   '411': [0.2195696764813696],
   '38': [0.30845342402732434],
   '331': [0.33774468469332175],
   '19': [0.33692534169353006],
   '98': [0.6609724666353921],
   '350': [0.3641149948327159],
   '490': [0.7354576006463468],
   '343': [0.7749488690868771],
   '345': [0.33115859213876697],
   '306': [0.23081051137357655],
   '416': [0.9950521695855612],
   '279': [0.6344648924365647],
   '84': [0.6868872136652032],
   '370': [0.37816278414611426],
   '341': [0.7093244132589273],
   '379': [0.37395157822840064],
   '139': [0.2722573485669788],
   '499': [0.28799255721800143],
   '235': [0.6276252307089174],
   '253': [0.00764261927703247],
   '302': [0.2608114918772392],
   '312': [0.15799345437151135],
   '181': [0.7948454499733166],
   '461': [0.6485285143268809],
   '342': [0.26193530730488546],
   '333': [0.7673001579153176],
   '168': [0.6372398469792355],
   '346': [0.03281032716629828],
   '465': [0.9924950061208353],
   '493': [0.6355276885452338],
   '420': [0.9218395447825463],
   '464': [0.21233974096623698],
   '448': [0.09016521064942029],
   '137': [0.3094476539569385],
   '484': [0.904813401388362],
   '82': [0.5436235847974143],
   '428': [0.512264905956655],
   '141': [0.19319435821189634],
   '478': [0.13840396010546252],
   '96': [0.3190095356693473],
   '437': [0.9480029362678147],
   '24': [0.8513973511268649],
   '45': [0.20623545414247413],
   '409': [0.035303578634837685],
   '67': [0.10746387094466336],
   '492': [0.7809176085784953],
   '359': [0.6703756736424107],
   '322': [0.01668447013683183],
   '365': [0.3856898624691746],
   '498': [0.569667563522764],
   '91': [0.65330552831149],
   '215': [0.671003238668619],
   '348': [0.23823069117215379],
   '267': [0.5008558735635051],
   '81': [0.2957246092147734],
   '494': [0.22130031875608358],
   '1': [0.4718413358396065],
   '426': [0.22331808088389526],
   '196': [0.44289338036930026],
   '147': [0.11335070654570234],
   '119': [0.5156477982135074],
   '281': [0.5983234823293404],
   '15': [0.13190828940639954],
   '354': [0.13003736520131437]},
  'interictal': {'186': [0.6272379297634044],
   '90': [0.02690982876396364],
   '404': [0.11876729081609805],
   '248': [0.835972507404039],
   '51': [0.01965721375177809],
   '8': [0.5889080213888311],
   '436': [0.9257922199791405],
   '193': [0.20668317824625493],
   '309': [0.39029412862583024],
   '449': [0.25143992673447846],
   '101': [0.992252218540992],
   '476': [0.9169632790774574],
   '286': [0.49656126386735555],
   '452': [0.2381487940443875],
   '219': [0.724354693281718],
   '447': [0.8209232286253008],
   '171': [0.08211282040075729],
   '215': [0.20038027067080766],
   '337': [0.3060911185829974],
   '217': [0.7036846862340221],
   '78': [0.5554447629138243],
   '408': [0.3285284556853466],
   '376': [0.4379353545446857],
   '68': [0.8072647736080465],
   '282': [0.750059933208587],
   '4': [0.8392688917543739],
   '35': [0.9719764780897763],
   '50': [0.32703538966196033],
   '402': [0.6422518312586016],
   '361': [0.4945182442376902],
   '413': [0.11518830877848019],
   '179': [0.06804252454037452],
   '152': [0.8103178307022957],
   '394': [0.8988656247451295],
   '241': [0.5808775832447964],
   '371': [0.655703394491149],
   '251': [0.2776844674948352],
   '106': [0.4466187609235279],
   '340': [0.34671486451436917],
   '59': [0.8884589539797919],
   '23': [0.8119243815831346],
   '169': [0.04624070694195648],
   '194': [0.9569834289855371],
   '274': [0.9944108009396342],
   '74': [0.5166219707702288],
   '73': [0.5032233314756869],
   '33': [0.4659212414565338],
   '444': [0.20985658791593875],
   '272': [0.7818212812718291],
   '201': [0.6839098554693153],
   '373': [0.6395015187768508],
   '63': [0.4602154438455741],
   '357': [0.5978944627521937],
   '273': [0.26309220501603503],
   '94': [0.36180955352246347],
   '39': [0.6727423177654306],
   '12': [0.0796198411347584],
   '123': [0.12328508226047552],
   '161': [0.4909290570357905],
   '301': [0.3020850062003263],
   '56': [0.9693279982789923],
   '425': [0.4183043855103463],
   '209': [0.7355450131167979],
   '52': [0.31902875199414293],
   '47': [0.9809235931068996],
   '362': [0.6863394485216656],
   '318': [0.9187252805029776],
   '5': [0.251481350247741],
   '264': [0.7521050664526656],
   '352': [0.9400238425208309],
   '480': [0.2299039302309165],
   '423': [0.3990838927591758],
   '143': [0.6300541280832043],
   '7': [0.10940628115909479],
   '48': [0.6949692815497088],
   '351': [0.1980256579064228],
   '37': [0.2604315512910743],
   '140': [0.4143547550462868],
   '280': [0.5725580614377326],
   '9': [0.26831387833174825],
   '165': [0.21118436854452272],
   '246': [0.16369836857757436],
   '238': [0.09321418248529667],
   '295': [0.3939647435694419],
   '195': [0.8235300285067658],
   '364': [0.11561300547526554],
   '69': [0.8011826133520973],
   '136': [0.9105188899237797],
   '310': [0.6975860687802228],
   '334': [0.754204971787796],
   '57': [0.22925888432744101],
   '46': [0.11599389833429175],
   '212': [0.1657153707641137],
   '197': [0.6956771115361191],
   '299': [0.3776133603351819],
   '121': [0.3677031986418744],
   '369': [0.5040718043589616],
   '133': [0.1992213754100598],
   '292': [0.8098626729110935],
   '156': [0.9583718188129797],
   '126': [0.029090505007849377],
   '42': [0.248555127171466],
   '388': [0.6391494628641471],
   '216': [0.018051160104676223],
   '26': [0.8433121063546907],
   '467': [0.26687889658784225],
   '308': [0.8559872227367329],
   '422': [0.1427911253159545],
   '359': [0.7095498300148753],
   '463': [0.27305351476320805],
   '27': [0.8672270092894122],
   '97': [0.9315585517111971],
   '258': [0.5162857286855695],
   '315': [0.977558121285872],
   '296': [0.2367077315171181],
   '419': [0.8044180127826712],
   '148': [0.6459896122877832],
   '418': [0.9679772285300674],
   '401': [0.683610849056346],
   '288': [0.11750301909568694],
   '257': [0.7597295604583558],
   '2': [0.10865164711767761],
   '153': [0.017434434878969896],
   '49': [0.7222558726576583],
   '384': [0.8649567563365159],
   '368': [0.10179264886116957],
   '349': [0.955833536550955],
   '269': [0.18858667855805644],
   '114': [0.765021214067308],
   '355': [0.12747251069040688],
   '335': [0.29380482241996897],
   '10': [0.5103186683416419],
   '85': [0.7466534576501759],
   '277': [0.7676664920556071],
   '166': [0.578956310870186],
   '382': [0.8466185428029078],
   '433': [0.5122905630143286],
   '125': [0.5950105544824512],
   '460': [0.3884813178925677],
   '95': [0.8157749510467633],
   '435': [0.5178018965185289],
   '173': [0.08072280750985206],
   '70': [0.5790061640215137],
   '72': [0.3022209324341082],
   '75': [0.48194464500893164],
   '375': [0.2700285176689877],
   '162': [0.3400423842614406],
   '324': [0.7261371509068967],
   '367': [0.052567588615968],
   '441': [0.5466033365641602],
   '290': [0.9006731856386117],
   '431': [0.07493549887412487],
   '472': [0.7605625468860624],
   '203': [0.8010143891298079],
   '456': [0.24982358089504975],
   '88': [0.0775857368226549],
   '393': [0.275513176753872],
   '254': [0.21024726564427232],
   '112': [0.17114872332141196],
   '191': [0.6638047975438959],
   '270': [0.8588235324522621],
   '115': [0.4455262905658435],
   '185': [0.6470680955076711],
   '477': [0.44797052366617307],
   '71': [0.5075156635240268],
   '28': [0.49217586457545237],
   '178': [0.5342134438319552],
   '104': [0.9631262890665977],
   '190': [0.3505606336955367],
   '385': [0.4031382806873406],
   '284': [0.17474118581214482],
   '134': [0.5244205013020666],
   '372': [0.5058069324589035],
   '329': [0.2912372504471842],
   '304': [0.8208741562966931],
   '65': [0.31545055641724074],
   '211': [0.7496716149070671],
   '442': [0.9777757982618737],
   '54': [0.45401158583335666],
   '271': [0.9801699448379266],
   '378': [0.7260220281279975],
   '356': [0.1144837715990763],
   '421': [0.6322570139856962],
   '129': [0.3446435421395857],
   '256': [0.8983074907646325],
   '374': [0.2941179524493983],
   '66': [0.36618107492030205],
   '249': [0.35600101441408727],
   '3': [0.34504310781148384],
   '239': [0.8261811655641561],
   '276': [0.21866605269797534],
   '398': [0.7472685748356436],
   '455': [0.877745945679912],
   '474': [0.8149036261643572],
   '314': [0.5199749006051329],
   '107': [0.9153796918163161],
   '218': [0.5731159347205842],
   '389': [0.16280941920106629],
   '236': [0.528545984979021],
   '180': [0.7983600299848208],
   '17': [0.8363877783136772],
   '454': [0.6611389690642446],
   '132': [0.1464858155967873],
   '222': [0.8225152923211626],
   '160': [0.3813264500485305],
   '31': [0.7979997881704586],
   '55': [0.816453972854741],
   '325': [0.04174113732953599],
   '366': [0.447154720909805],
   '200': [0.7659728814873812],
   '380': [0.32159780620864375],
   '261': [0.5763163252120193],
   '29': [0.19386479436140047],
   '289': [0.47262121567258386],
   '93': [0.260715029797834],
   '87': [0.7049731342838238],
   '262': [0.5536703029312086],
   '339': [0.6113413251285655],
   '32': [0.42615188482968036],
   '40': [0.527694109216308],
   '307': [0.15997635621686956],
   '451': [0.24334053176302084],
   '287': [0.6627706410726601],
   '316': [0.21604517771252585],
   '149': [0.5628112656328274],
   '323': [0.37661001020388873],
   '188': [0.13527136748974244],
   '291': [0.552323468770637],
   '298': [0.1775786475673673],
   '326': [0.815061718889196],
   '347': [0.5080493690555853],
   '255': [0.9935834809865635],
   '116': [0.0576292801943139],
   '250': [0.7681839049475083],
   '207': [0.1762537173184051],
   '336': [0.3496426714226575],
   '16': [0.7394644807374353],
   '381': [0.7257182239644852],
   '224': [0.11531318164392634],
   '332': [0.20126044810922594],
   '412': [0.26883771921711563],
   '213': [0.11786571936359169],
   '475': [0.27515206521077795],
   '60': [0.10038185129241717],
   '163': [0.8346284349672176],
   '127': [0.4768502600465],
   '231': [0.02098290711688644],
   '20': [0.021528674872354214],
   '208': [0.768627575543823],
   '232': [0.0057426771088230355],
   '34': [0.9605288559289541],
   '386': [0.24499716890318168],
   '268': [0.10446888576234115],
   '266': [0.0065337500379060165],
   '471': [0.33898430279339364],
   '214': [0.9591328675587939],
   '182': [0.2486736193024608],
   '135': [0.9091168361440167],
   '204': [0.8984585207975448],
   '131': [0.8637028245526684],
   '406': [0.4400067546099651],
   '142': [0.46079408859869453],
   '466': [0.6010151919998766],
   '172': [0.6816958213168297],
   '390': [0.48187256462103],
   '252': [0.32186611307911894],
   '245': [0.16016287765179427],
   '328': [0.7216470980565709],
   '221': [0.29477260080542755],
   '21': [0.9430467495155235],
   '86': [0.5096351503729738],
   '30': [0.17788399027462343],
   '453': [0.5976905594716851],
   '415': [0.0033660387239448086],
   '247': [0.7782654756647401],
   '438': [0.20789239672256354],
   '392': [0.27925966242494127],
   '53': [0.982665697003912],
   '233': [0.26521008264688195],
   '128': [0.18301006242211626],
   '358': [0.08103713057340467],
   '443': [0.09760820090615807],
   '64': [0.8695485417385784],
   '36': [0.8118047926097964],
   '300': [0.3686968442681301],
   '396': [0.29674265415163326],
   '244': [0.9270586423488351],
   '383': [0.2874091790428607],
   '138': [0.8736730316009411],
   '405': [0.23703264150689007],
   '223': [0.5935084780628335],
   '77': [0.9958161712913617],
   '43': [0.473416420716249],
   '102': [0.9187684624780257],
   '113': [0.678987530920848],
   '167': [0.374092144480314],
   '174': [0.7878225581633923],
   '22': [0.050841135741996446],
   '105': [0.3315361590336984],
   '76': [0.28625256834051993],
   '109': [0.11031447286341756],
   '344': [0.1219472860445856],
   '410': [0.6250333297545232],
   '150': [0.7640857377721669],
   '176': [0.7589216801360393],
   '157': [0.877864805539897],
   '62': [0.7366025586087531],
   '155': [0.37939083310154675],
   '14': [0.06611106579289361],
   '124': [0.9765775029203598],
   '205': [0.27358156801694744],
   '6': [0.07678176814178417],
   '397': [0.8959749045138944],
   '303': [0.9067194612721372],
   '479': [0.45329623391655616],
   '391': [0.8303212792176822],
   '360': [0.1260900954355968],
   '317': [0.598549593998504],
   '321': [0.22666903523198312],
   '108': [0.08812743354018615],
   '110': [0.7476126092839149],
   '430': [0.8315023079753202],
   '61': [0.6618115614680695],
   '283': [0.7231997673779661],
   '92': [0.5356162935741615],
   '175': [0.637785529626851],
   '229': [0.4148993203484065],
   '80': [0.7369368138457044],
   '228': [0.5689110147800516],
   '400': [0.36501971901071717],
   '240': [0.17377138562061312],
   '319': [0.6635012923568806],
   '278': [0.5911771751851018],
   '118': [0.6952022226282857],
   '189': [0.10582286877849045],
   '445': [0.9764675572326749],
   '11': [0.6950634828128179],
   '230': [0.8142902179313366],
   '184': [0.824754419322321],
   '263': [0.9247276080056993],
   '41': [0.8403341787133747],
   '338': [0.05429786332464848],
   '159': [0.40157103262693583],
   '146': [0.911987411853809],
   '424': [0.13091938851379092],
   '243': [0.672997405673454],
   '227': [0.35120627369535107],
   '417': [0.2557739722247139],
   '439': [0.8553671676161184],
   '44': [0.07513449041118703],
   '469': [0.3139468182198627],
   '206': [0.8802731239659951],
   '187': [0.8714097764376887],
   '446': [0.49233327000818106],
   '237': [0.7486640937573594],
   '83': [0.96507815236376],
   '468': [0.3095643325240849],
   '122': [0.5395626839528906],
   '285': [0.5155523935130613],
   '353': [0.9215770494914086],
   '220': [0.9000937203299904],
   '13': [0.5211064509895457],
   '192': [0.5646831293691923],
   '432': [0.10340737697427238],
   '99': [0.5678081021297822],
   '58': [0.3425010534533117],
   '305': [0.32458249875552225],
   '399': [0.1449109132091576],
   '260': [0.0677118436388442],
   '103': [0.3112425192127479],
   '320': [0.7075307301860791],
   '130': [0.9690329754862878],
   '363': [0.8452363120684969],
   '414': [0.05377394279377978],
   '473': [0.2625457789903062],
   '403': [0.3605343093609469],
   '226': [0.21819776068336227],
   '429': [0.648128286412386],
   '462': [0.590062854830146],
   '293': [0.5721486171241352],
   '242': [0.13800702468597748],
   '154': [0.2805065157361145],
   '79': [0.058294262913170414],
   '144': [0.7770572736319695],
   '210': [0.39183084518393996],
   '234': [0.8213870827644919],
   '457': [0.2140371402643445],
   '111': [0.3023175608853109],
   '470': [0.2868581166013435],
   '151': [0.6516725574188812],
   '313': [0.5034439860298257],
   '183': [0.4766728162595123],
   '407': [0.38721600532419875],
   '265': [0.6305316305055448],
   '459': [0.8446502769207099],
   '377': [0.9611577597294918],
   '327': [0.5158954374978962],
   '199': [0.8877292316417872],
   '25': [0.5861995142543037],
   '141': [0.641404931412534],
   '311': [0.6270554167958189],
   '225': [0.6851554757454517],
   '117': [0.9671727527079645],
   '120': [0.9256805661453553],
   '100': [0.5453001240529992],
   '395': [0.33685466686254295],
   '198': [0.17611543459366208],
   '330': [0.8175613297105249],
   '427': [0.6794598862666218],
   '434': [0.43905109739507775],
   '259': [0.10612505858998422],
   '440': [0.990077586468185],
   '164': [0.40681544941461867],
   '458': [0.8848056588754081],
   '89': [0.6617857003708671],
   '170': [0.3543161533315371],
   '177': [0.22777459491699403],
   '18': [0.7337738679794876],
   '202': [0.18289473959515345],
   '275': [0.4956870630139253],
   '297': [0.3426230154482428],
   '411': [0.2602045071974082],
   '38': [0.946167874141106],
   '331': [0.841244760231072],
   '19': [0.290478198836816],
   '98': [0.45833400332381113],
   '350': [0.9139951839536665],
   '343': [0.2760969139272592],
   '345': [0.6922365813328732],
   '306': [0.2313442699952405],
   '416': [0.464892045177279],
   '279': [0.8948542827534623],
   '84': [0.9557758748948209],
   '370': [0.02517254936474822],
   '341': [0.9965780360213279],
   '81': [0.8248315502212086],
   '379': [0.6073562955719886],
   '139': [0.7378533701913472],
   '235': [0.6049065468002043],
   '253': [0.19225942922684025],
   '302': [0.6127643573475844],
   '312': [0.1592074119349921],
   '181': [0.19600479369064894],
   '461': [0.39489127152911385],
   '342': [0.6255669070807033],
   '333': [0.11147653104478183],
   '168': [0.046757246140245345],
   '346': [0.9379975059757218],
   '465': [0.5684575352099336],
   '294': [0.014320086657474529],
   '420': [0.8880965688973361],
   '464': [0.17586697064473034],
   '448': [0.47874575293935884],
   '137': [0.6606155149958347],
   '82': [0.21969115298011155],
   '428': [0.4993313246557174],
   '478': [0.42587324506824986],
   '96': [0.9685633478573],
   '437': [0.9026742829853768],
   '24': [0.6972407871371145],
   '45': [0.5674501229108595],
   '409': [0.988793151052608],
   '67': [0.4861746306595661],
   '450': [0.46625589030003],
   '158': [0.5803645541152124],
   '322': [0.9222198642489626],
   '365': [0.07150769526308876],
   '91': [0.1673085049943861],
   '145': [0.3432536873514689],
   '348': [0.7789222008640231],
   '267': [0.5904998424659462],
   '15': [0.2833140718036006],
   '1': [0.46082900406327765],
   '426': [0.48314984962888385],
   '196': [0.6209209346552017],
   '147': [0.5432794313899858],
   '119': [0.5376580405865439],
   '281': [0.9618578227788076],
   '387': [0.30565248799475564],
   '354': [0.462787661944006]},
  'preictal': {'19': [0.5751373782630792],
   '2': [0.32036944199450523],
   '4': [0.982187171857782],
   '13': [0.950038017344332],
   '21': [0.224641541534928],
   '24': [0.7855452393806281],
   '18': [0.24721538682439104],
   '16': [0.8714695635751384],
   '22': [0.8646691776166601],
   '7': [0.716693491388096],
   '20': [0.6254787648791436],
   '14': [0.6484754472953268],
   '9': [0.6211821535086461],
   '3': [0.5419671435228954],
   '6': [0.34701091763113157],
   '17': [0.5289655826833892],
   '10': [0.9245822446174692],
   '1': [0.09873317265533987],
   '12': [0.5867740670618006],
   '8': [0.5211401849999311],
   '11': [0.18748837706706922],
   '5': [0.7084182630281614],
   '15': [0.9417857549148925],
   '23': [0.12522105286576235]}},
 'description': 'A useless dummy feature.'}

Removing a document

I accidentally added a second dummy feature above with a the name "the dummy feature" rather than just "dummy". Can remove it like this:


In [79]:
for feature in collection.find():
    print(feature["name"])


dummy
the dummy feature

In [80]:
# first find it's id
dummyid = collection.find_one({"name":"the dummy feature"})['_id']
# then remove it
collection.remove(spec_or_id=dummyid)


Out[80]:
{'err': None,
 'n': 1,
 'ok': 1.0,
 'connectionId': 155160,
 'lastOp': Timestamp(1411941997, 1)}

Checking if it's still there by looking through all the documents in this collection:


In [81]:
for feature in collection.find():
    print(feature["name"])


dummy