Skip to content

checking how many neurosynth studies are in studysets not owned by developers the platform

James Kent edited this page Apr 23, 2024 · 1 revision
ls
from sqlalchemy.orm import joinedload
User.name
User.name.ilike("James").all()
User.query.filter(User.name.ilike("James")).all()
User.query.filter(User.name.ilike("%James%")).all()
User.query.filter(User.name.ilike("%James%")).all()[0].name
User.query.filter(User.name.ilike("%James%")).all()[1].name
User.query.filter(User.name.ilike("%James%")).all()[2].name
User.query.filter(User.name.ilike("%James%")).all()[3].name
User.query.filter(User.name.ilike("%James%")).all()[1].name
User.query.filter(User.name.ilike("%James%")).all()[1].username
User.query.filter(User.name.ilike("%James%")).all()[1].id
User.query.filter(User.name.ilike("%James%")).all()[1].external_id
ignore_ids = [u.external_id for u in User.query.filter(User.name.ilike("%James%")).all()[1:]]
User.query.filter(User.name.ilike("%Alejandro%")).all()[1].external_id
User.query.filter(User.name.ilike("%Alejandro%")).all()
User.query.filter(User.name.ilike("%Alejandro%")).all()[0]
User.query.filter(User.name.ilike("%Alejandro%")).all()[0].name
User.query.filter(User.name.ilike("%Alejandro%")).all()[1].name
User.query.filter(User.name.ilike("%adel%"))
User.query.filter(User.name.ilike("%adel%")).all()
User.query.filter(User.name.ilike("%del%")).all()
User.query.filter(User.name.ilike("%del%")).all()[0]
User.query.filter(User.name.ilike("%del%")).all()[0].name
User.query.filter(User.name.ilike("%del%")).all()[1].name
ignore_ids.extend(User.query.filter(User.name.ilike("%Alejandro%")).all())
ignore_ids
ignore_ids[3] = ignore_ids[3].external_id
ignore_ids[4] = ignore_ids[4].external_id
ignore_ids
User.query.filter(User.name.ilike("%Nick%")).all()
User.query.filter(User.name.ilike("%Nick%")).all()[0].name
User.query.filter(User.name.ilike("%Nick%")).all()[1].name
User.query.filter(User.name.ilike("%Nick%")).all()[2].name
User.query.filter(User.name.ilike("%nick%")).all()
User.query.filter(User.name.ilike("%nick%")).all()[0]
User.query.filter(User.name.ilike("%nick%")).all()[0].name
User.query.filter(User.name.ilike("%nick%")).all()[1].name
User.query.filter(User.name.ilike("%lee%")).all()
User.query.filter(User.name.ilike("%lee%")).all()[0]
User.query.filter(User.name.ilike("%lee%")).all()[0].name
User.query.filter(User.name.ilike("%lee%")).all()[1].name
User.query.filter(User.name.ilike("%lee%")).all()[2].name
User.query.filter(User.name.ilike("%lee%")).all()[3].name
User.query.filter(User.name.ilike("%lee%")).all()[4].name
User.query.filter(User.name.ilike("%lee%")).all()[5].name
User.query.filter(User.name.ilike("%lee%")).all()[6].name
User.query.filter(User.name.ilike("%lee%")).all()[7].name
User.query.filter(User.name.ilike("%nich%")).all()
User.query.filter(User.name.ilike("%nich%")).all()[0]
User.query.filter(User.name.ilike("%nich%")).all()[0].name
User.query.filter(User.name.ilike("%nich%")).all()[1].name
User.query.filter(User.name.ilike("%nicholas%")).all()[1].name
User.query.filter(User.name.ilike("%nicholas%")).all()
User.query.filter(User.name.ilike("%nicholas%")).all()[0]
User.query.filter(User.name.ilike("%nicholas%")).all()[0].name
User.query.filter(User.name.ilike("%nicholas%")).all()[1].name
User.query.filter(User.name.ilike("%nicholas%")).all()[2].name
User.query.filter(User.name.ilike("%nicholas%")).all()[3].name
User.query.filter(User.name.ilike("%nicholas%")).all()[4].name
User.query.filter(User.name.ilike("%nicholas%")).all()[5].name
User.query.filter(User.name.ilike("%nicholas%")).all()[6].name
User.query.filter(User.name.ilike("%nicholas%")).all()[0].name
User.query.filter(User.name.ilike("%nicholas%")).all()[1].name
User.query.filter(User.name.ilike("%nicholas%")).all()[2].name
User.query.filter(User.name.ilike("%nicholas%")).all()[:2]
User.query.filter(User.name.ilike("%nicholas%")).all()[:3]
User.query.filter(User.name.ilike("%nicholas%")).all()[:3][1].name
ignore_ids.extend(u.external_id for u in User.query.filter(User.name.ilike("%nicholas%")).all()[:3])
ignore_ids
Studyset.query.first.user
Studyset.query.first().user
Studyset.query.filter(Studyset.user != None).first().user
Studyset.query.filter(Studyset.user != None).first().user_id
Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()
len(Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all())
session = db.session
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets)))
excluded_studysets = Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()
[ss for ss in excluded_studysets if "4x4NsrWg8heS" == ss.id]
Studyset.query.filter_by(id="4x4NsrWg8heS").one()
Studyset.query.filter_by(id="5CsCuX6hnCfQ").one()
excluded_studysets = Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets)))
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.in_(excluded_studysets)))
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()]
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.in_(excluded_studysets)))
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets)))
query.all()
all(query.all())
len(query.all())
neurosynth_studies_in_studysets = query.all()
neurosynth_studies_in_studysets = query.all()
neurosynth_studies_in_studysets[0].studysets
neurosynth_studies_in_studysets[0].studysets[0]
neurosynth_studies_in_studysets[0].studysets[1]
neurosynth_studies_in_studysets[0].studysets[0]
neurosynth_studies_in_studysets[0].studysets[0].studies
len(neurosynth_studies_in_studysets[0].studysets[0].studies)
neurosynth_studies_in_studysets[0].studysets[0].name
ignore_ids
ignore_ids.append(None)
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()]
len(excluded_studysets
)
ignore_ids
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets), Studyset.user_id.is_(None)))
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets) & Studyset.user_id.is_(None)))
query.all()
len(query.all())
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets) | Studyset.user_id.is_(None)))
len(query.all())
len(query.all())
neurosynth_studies_in_studysets = query.all()
neurosynth_studies_in_studysets[0].name
neurosynth_studies_in_studysets[0].studysets
neurosynth_studies_in_studysets[0].studysets[0
]
neurosynth_studies_in_studysets[0].studysets[0]
neurosynth_studies_in_studysets[0].studysets
list(neurosynth_studies_in_studysets[0].studysets)
list(neurosynth_studies_in_studysets[1].studysets)
list(neurosynth_studies_in_studysets[2].studysets)
list(neurosynth_studies_in_studysets[3].studysets)
list(neurosynth_studies_in_studysets[4].studysets)
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets))).filter(~Study.studysets.any(Studyset.user_id.is_(None)))
len(query.all())
len(exlcuded_studysets)
len(excluded_studysets)
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()]
len(excluded_studysets)
ignore_ids
ignore_ids.pop(None)
ignore_ids.pop()
ignore_ids
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()]
len(excluded_studysets)
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets))).filter(~Study.studysets.any(Studyset.user_id.is_(None)))
len(query.all()
)
query.all()[0].studysets
query.all()[0].studysets[0]
list(query.all()[0])
list(query.all()[0].studysets)
query = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets))).filter(~Study.studysets.any(Studyset.user_id.is_(None))).filter(Study.studysets.any())
list(query.all()[0].studysets)
list(query.all()
)
session.query.filter(Study.studysets.any())
session.query(Study).filter(Study.studysets.any())
session.query(Study).filter(Study.studysets.any()).all()
len(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").all())
len(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).all())
session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).all()[0].studysets
len(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).all()[0].studysets)
list(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).all()[0].studysets)
list(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).all()[2].studysets)
list(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets)))
)
len(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets)))
)
len(session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets))).all())
session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets))).all()
neurosynth_studies = session.query(Study).filter(Study.studysets.any()).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets))).all()
neurosynth_studies[0].studysets
list(neurosynth_studies[0].studysets)
list(neurosynth_studies[100].studysets)
list(neurosynth_studies[104].studysets)
neurosynth_studies[104].name
set(neurosynth_studies[104].studysets)
{s.id for s in neurosynth_studies[104].studysets} - excluded_studysets
{s.id for s in neurosynth_studies[104].studysets} - set(excluded_studysets)
neurosynth_studies[104].studysets[1].name
neurosynth_studies[104].studysets[1].user
neurosynth_studies[104].studysets[1].id
neurosynth_studies[104].studysets[1].user_id
neurosynth_studies = session.query(Study).filter(Study.source == "neurosynth").filter(Study.studysets.any(Studyset.user_id != None)).filter(Study.studysets.any(Studyset.id.notin_(excluded_studysets))).filter(Study.studysets.any()).all()
len(neurosynth_studies)
neurosynth_studies = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(Study.studysets.any(Studyset.user_id != None))\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets)))\
    .filter(Study.studysets.any())\
    .all()
len(neurosynth_studies)
neurosynth_studies[0].studysets
list(neurosynth_studies[0].studysets)
list(neurosynth_studies[0].studysets)[0].name
list(neurosynth_studies[0].studysets)[1].name
list(neurosynth_studies[0].studysets)[2].name
list(neurosynth_studies[0].studysets)[2].username
list(neurosynth_studies[0].studysets)[2].user
list(neurosynth_studies[0].studysets)[2].user.name
list(neurosynth_studies[0].studysets)[2].user.external_id
list(neurosynth_studies[0].studysets)[0]
list(neurosynth_studies[0].studysets)[0].user
list(neurosynth_studies[0].studysets)[0].user_id
list(neurosynth_studies[0].studysets)[1].user_id
list(neurosynth_studies[0].studysets)[2].user_id
ignore_ids
list(neurosynth_studies[0].studysets)[2].id
list(neurosynth_studies[0].studysets)[2].id in excluded_studysets
excluded_studysets
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.notin_(ignore_ids)).all()]
excluded_studysets = [ss.id for ss in Studyset.query.filter(Studyset.user_id.in_(ignore_ids)).all()]
len(excluded_studysets
)
neurosynth_studies = session.query(Study)\
    .filter(Study.source == "neurosynth")\
    .filter(Study.studysets.any(Studyset.user_id != None))\
    .filter(~Study.studysets.any(Studyset.id.in_(excluded_studysets)))\
    .filter(Study.studysets.any())\
    .all()
len(neurosynth_studies)
neurosynth_studies[0]
list(neurosynth_studies[0].studysets)
list(neurosynth_studies[0].studysets)[0].name
list(neurosynth_studies[0].studysets)[1].name
list(neurosynth_studies[0].studysets)[2].name
list(neurosynth_studies[0].studysets)[2].user
list(neurosynth_studies[0].studysets)[2].user.name
history