File size: 7,340 Bytes
478fb4a ba3daf8 478fb4a ba3daf8 478fb4a a92ee6d 478fb4a ba3daf8 986dc0b 478fb4a b858b8c 478fb4a 78b3d77 478fb4a 78b3d77 478fb4a 78b3d77 ba3daf8 478fb4a 5c854fe 478fb4a 78b3d77 ba3daf8 478fb4a 6404fdb a92ee6d 478fb4a 986dc0b 478fb4a 30d8bff 478fb4a ae658d3 a2eb370 478fb4a a2eb370 ae658d3 478fb4a a2eb370 478fb4a a2eb370 ae658d3 478fb4a c0f8583 478fb4a ba3daf8 a92ee6d 5c854fe ba3daf8 646dfe5 8808a61 ba3daf8 48e6885 ba3daf8 93e0813 ba3daf8 93e0813 ba3daf8 93e0813 ba3daf8 c5edc51 ba3daf8 c5edc51 ba3daf8 c5edc51 ba3daf8 c5edc51 ba3daf8 c5edc51 ba3daf8 a92ee6d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# -*- coding: utf-8 -*-
"""aphantasia_drawing_dataset.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1DYVroeFqoNK7DDiw_3OIczPeqEME-rbh
"""
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pandas as pd
import numpy as np
import io
from typing import List
import datasets
import logging
from PIL import Image
_CITATION = """\
@misc{Bainbridge_Pounder_Eardley_Baker_2023,
title={Quantifying Aphantasia through drawing: Those without visual imagery show deficits in object but not spatial memory},
url={osf.io/cahyd},
publisher={OSF},
author={Bainbridge, Wilma A and Pounder, Zoë and Eardley, Alison and Baker, Chris I},
year={2023},
month={Sep}
}
"""
_DESCRIPTION = """\
This dataset comes from the Brain Bridge Lab from the University of Chicago.
It is from an online memory drawing experiment with 61 individuals with aphantasia
and 52 individuals with normal imagery. In the experiment participants 1) studied 3 separate
scene photographs presented one after the other, 2) then drew them from memory,
3) completed a recognition task, 4) copied the images while viewing them, 5) filled out
a VVIQ and OSIQ questionnaire and also demographics questions. The data from the experiment
was made available on the OSF website linked above. It was created July 31, 2020 and last
updated September 27, 2023.
"""
_HOMEPAGE = "https://osf.io/cahyd/"
url = "https://drive.google.com/file/d/1v1oaZog5j5dD_vIElOEWLCZUrXvJ3jzx/view?usp=drive_link"
def _get_drive_url(url):
base_url = 'https://drive.google.com/uc?id='
split_url = url.split('/')
return base_url + split_url[5]
_URL = {"train": _get_drive_url(url)}
class AphantasiaDrawingDataset(datasets.GeneratorBasedBuilder):
_URL = _URL
VERSION = datasets.Version("1.1.0")
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"subject_id": datasets.Value("int32"),
"treatment": datasets.Value("string"),
"demographics": {
"country": datasets.Value("string"),
"age": datasets.Value("int32"),
"gender": datasets.Value("string"),
"occupation": datasets.Value("string"),
"art_ability": datasets.Value("int32"),
"art_experience": datasets.Value("string"),
"device": datasets.Value("string"),
"input": datasets.Value("string"),
"difficult": datasets.Value("string"),
"diff_explanation": datasets.Value("string"),
"vviq_score": datasets.Value("int32"),
"osiq_score": datasets.Value("int32")
},
"drawings": {
"kitchen": {
"perception": datasets.Image(decode=True),
"memory": datasets.Image(decode=True)
},
"livingroom": {
"perception": datasets.Image(decode=True),
"memory": datasets.Image(decode=True)
},
"bedroom": {
"perception": datasets.Image(decode=True),
"memory": datasets.Image(decode=True)
}
},
"image": {
"kitchen": datasets.Image(decode=True),
"livingroom": datasets.Image(decode=True),
"bedroom": datasets.Image(decode = True)
}
}),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION
)
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
url_to_download = self._URL
downloaded_file = dl_manager.download_and_extract(url_to_download)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={
"filepath": downloaded_file["train"]
})
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
logging.info("generating examples from = %s", filepath)
def byt_to_image(image_bytes):
if image_bytes is not None:
image_buffer = io.BytesIO(image_bytes)
image = Image.open(image_buffer)
return image
return None
with open(filepath, "rb") as subjects_file:
subjects_data = pd.read_parquet(subjects_file)
for idx, sub_row in subjects_data.iterrows():
yield idx, {
"subject_id": sub_row["subject_id"],
"treatment": sub_row["treatment"],
"demographics": {
"country": sub_row["demographics.country"],
"age": sub_row["demographics.age"],
"gender": sub_row["demographics.gender"],
"occupation": sub_row["demographics.occupation"],
"art_ability": sub_row["demographics.art_ability"],
"art_experience": sub_row["demographics.art_experience"],
"device": sub_row["demographics.device"],
"input": sub_row["demographics.input"],
"difficult": sub_row["demographics.difficult"],
"diff_explanation": sub_row["demographics.diff_explanation"],
"vviq_score": sub_row["demographics.vviq_score"],
"osiq_score": sub_row["demographics.osiq_score"]
},
"drawings": {
"kitchen": {
"perception": byt_to_image(sub_row["drawings.kitchen.perception"]),
"memory": byt_to_image(sub_row["drawings.kitchen.memory"])
},
"livingroom": {
"perception": byt_to_image(sub_row["drawings.livingroom.perception"]),
"memory": byt_to_image(sub_row["drawings.livingroom.memory"])
},
"bedroom": {
"perception": byt_to_image(sub_row["drawings.bedroom.perception"]),
"memory": byt_to_image(sub_row["drawings.bedroom.memory"])
}
},
"image": {
"kitchen": byt_to_image(sub_row["image.kitchen"]),
"livingroom": byt_to_image(sub_row["image.livingroom"]),
"bedroom": byt_to_image(sub_row["image.bedroom"])
}
}
|