Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions bcipy/core/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def alphabet(parameters: Optional[Any] = None, include_path: bool = True,
stimulus_array: List[str] = []
for stimulus_filename in sorted(os.listdir(path)):
# PLUS.png is reserved for the fixation symbol
if stimulus_filename.endswith(
'.png') and not stimulus_filename.endswith('PLUS.png'):
root, ext = os.path.splitext(stimulus_filename)
if ext in [".png", ".bmp", ".jpg"] and not root.endswith("PLUS"):
if include_path:
img = os.path.join(path, stimulus_filename)
else:
img = os.path.splitext(stimulus_filename)[0]
img = root
stimulus_array.append(img)
return stimulus_array

Expand Down
Binary file added bcipy/core/tests/resources/images/1x1_PLUS.bmp
Binary file not shown.
Binary file added bcipy/core/tests/resources/images/1x1_PLUS.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bcipy/core/tests/resources/images/1x1_PLUS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bcipy/core/tests/resources/images/a_1x1.bmp
Binary file not shown.
Binary file added bcipy/core/tests/resources/images/b_1x1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bcipy/core/tests/resources/images/c_1x1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions bcipy/core/tests/resources/images/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Text file for testing only images are collected from the folder.
27 changes: 19 additions & 8 deletions bcipy/core/tests/test_symbols.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from bcipy.core.symbols import alphabet

from typing import Dict

class TestAlphabet(unittest.TestCase):
def test_alphabet_text(self):
Expand All @@ -17,15 +17,26 @@ def test_alphabet_text(self):
'<', '_'
])

def test_alphabet_images(self):
parameters = {}
def test_alphabet_images_with_path(self):
path = 'bcipy/core/tests/resources/images/'
parameters: Dict[str, bool | str] = {}
parameters['is_txt_stim'] = False
parameters['path_to_presentation_images'] = ('bcipy/static/images/'
'rsvp/')
parameters['path_to_presentation_images'] = path

alp = alphabet(parameters)

self.assertNotEqual(alp, [
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'Y', 'Z', '<', '_'
self.assertEqual(alp, [
path + 'a_1x1.bmp',
path + 'b_1x1.jpg',
path + 'c_1x1.png'
])

def test_alphabet_images_without_path(self):
path = 'bcipy/core/tests/resources/images/'
parameters: Dict[str, bool | str] = {}
parameters['is_txt_stim'] = False
parameters['path_to_presentation_images'] = path

alp = alphabet(parameters, include_path=False)

self.assertEqual(alp, ['a_1x1', 'b_1x1', 'c_1x1'])
2 changes: 1 addition & 1 deletion bcipy/display/paradigm/rsvp/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def _generate_inquiry(self) -> List[Dict[str, Any]]:
this_stimuli_size = (self.size_list_sti[idx] if self.size_list_sti
else self.stimuli_height)

if stim.endswith('.png'):
if any([stim.endswith(ext) for ext in [".png", ".bmp", ".jpg"]]):
current_stim['sti'] = self._create_stimulus(
mode='image',
height=this_stimuli_size,
Expand Down
2 changes: 1 addition & 1 deletion bcipy/parameters/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"value": "bcipy/static/images/rsvp/",
"section": "bci_config",
"name": "Image Stimulus Folder",
"helpTip": "Specifies the location of image files to be used as stimuli (Text Stimuli On/Off must be set to ‘false’). This must be a directory ending with /.",
"helpTip": "Specifies the location of image files to be used as stimuli (Text Stimuli On/Off must be set to ‘false’). This must be a directory ending with /. Image files must have extension .bmp, .jpg, or .png. Files ending in PLUS.bmp, PLUS.jpg, or PLUS.png, are ignored as they are assumed to be fixation images.",
"recommended": "",
"editable": false,
"type": "directorypath"
Expand Down
Loading