Skip to content

Commit

Permalink
Merge branch 'main' into SbxImagingInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyCBakerPhD authored Sep 29, 2023
2 parents 4413830 + 07a91ae commit 2e2c430
Show file tree
Hide file tree
Showing 9 changed files with 222 additions and 7 deletions.
5 changes: 5 additions & 0 deletions guideGlobalMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"KiloSortSortingInterface",
"Spike2RecordingInterface",
"BrukerTiffSinglePlaneImagingInterface",
"BrukerTiffMultiPlaneImagingInterface",
"MicroManagerTiffImagingInterface",
"ScanImageImagingInterface",
"TiffImagingInterface",
"MiniscopeImagingInterface",
"SbxImagingInterface"
]
}
22 changes: 16 additions & 6 deletions pyflask/manageNeuroconv/manage_neuroconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,32 @@ def replace_none_with_nan(json_object, json_schema):
dict: The modified JSON object with None values replaced by NaN.
"""

def replace_none_recursive(obj, schema):
def coerce_schema_compliance_recursive(obj, schema):
if isinstance(obj, dict):
for key, value in obj.items():
if key in schema.get("properties", {}):
prop_schema = schema["properties"][key]
if prop_schema.get("type") == "number" and value is None:
obj[key] = math.nan
obj[
key
] = (
math.nan
) # Turn None into NaN if a number is expected (JavaScript JSON.stringify turns NaN into None)
elif prop_schema.get("type") == "number" and isinstance(value, int):
obj[key] = float(
value
) # Turn integer into float if a number, the JSON Schema equivalent to float, is expected (JavaScript coerces floats with trailing zeros to integers)
else:
replace_none_recursive(value, prop_schema)
coerce_schema_compliance_recursive(value, prop_schema)
elif isinstance(obj, list):
for item in obj:
replace_none_recursive(item, schema.get("items", {}))
coerce_schema_compliance_recursive(item, schema.get("items", {}))

return obj

return replace_none_recursive(copy.deepcopy(json_object), resolve_references(copy.deepcopy(json_schema)))
return coerce_schema_compliance_recursive(
copy.deepcopy(json_object), resolve_references(copy.deepcopy(json_schema))
)


def locate_data(info: dict) -> dict:
Expand Down Expand Up @@ -363,7 +373,7 @@ def update_conversion_progress(**kwargs):
info["metadata"].update(Ecephys=dict())

resolved_metadata = replace_none_with_nan(
info["metadata"], converter.get_metadata_schema()
info["metadata"], resolve_references(converter.get_metadata_schema())
) # Ensure Ophys NaN values are resolved

# if is_supported_recording_interface(recording_interface, info["metadata"]):
Expand Down
33 changes: 33 additions & 0 deletions schemas/json/generated/BrukerTiffMultiPlaneImagingInterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"required": [],
"properties": {
"BrukerTiffMultiPlaneImagingInterface": {
"required": [
"folder_path"
],
"properties": {
"folder_path": {
"format": "directory",
"type": "string",
"description": "The path that points to the folder containing the Bruker volumetric TIF image files and configuration files."
},
"stream_name": {
"type": "string"
},
"verbose": {
"type": "boolean",
"default": true
}
},
"type": "object",
"additionalProperties": false
}
},
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "source.schema.json",
"title": "Source data schema",
"description": "Schema for the source data, files and directories",
"version": "0.1.0"
}
30 changes: 30 additions & 0 deletions schemas/json/generated/MicroManagerTiffImagingInterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"required": [],
"properties": {
"MicroManagerTiffImagingInterface": {
"required": [
"folder_path"
],
"properties": {
"folder_path": {
"format": "directory",
"type": "string",
"description": "The path that points to the folder containing the OME-TIF image files."
},
"verbose": {
"type": "boolean",
"default": true
}
},
"type": "object",
"additionalProperties": false
}
},
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "source.schema.json",
"title": "Source data schema",
"description": "Schema for the source data, files and directories",
"version": "0.1.0"
}
25 changes: 25 additions & 0 deletions schemas/json/generated/MiniscopeImagingInterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"required": [],
"properties": {
"MiniscopeImagingInterface": {
"required": [
"folder_path"
],
"properties": {
"folder_path": {
"format": "directory",
"type": "string"
}
},
"type": "object",
"additionalProperties": false
}
},
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "source.schema.json",
"title": "Source data schema",
"description": "Schema for the source data, files and directories",
"version": "0.1.0"
}
33 changes: 33 additions & 0 deletions schemas/json/generated/ScanImageImagingInterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"required": [],
"properties": {
"ScanImageImagingInterface": {
"required": [
"file_path"
],
"properties": {
"file_path": {
"format": "file",
"type": "string",
"description": "Path to Tiff file."
},
"fallback_sampling_frequency": {
"type": "number"
},
"verbose": {
"type": "boolean",
"default": true
}
},
"type": "object",
"additionalProperties": false
}
},
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "source.schema.json",
"title": "Source data schema",
"description": "Schema for the source data, files and directories",
"version": "0.1.0"
}
34 changes: 34 additions & 0 deletions schemas/json/generated/TiffImagingInterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"required": [],
"properties": {
"TiffImagingInterface": {
"required": [
"file_path",
"sampling_frequency"
],
"properties": {
"file_path": {
"format": "file",
"type": "string",
"description": "Path to Tiff file."
},
"sampling_frequency": {
"type": "number"
},
"verbose": {
"type": "boolean",
"default": true
}
},
"type": "object",
"additionalProperties": false
}
},
"type": "object",
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "source.schema.json",
"title": "Source data schema",
"description": "Schema for the source data, files and directories",
"version": "0.1.0"
}
2 changes: 1 addition & 1 deletion src/renderer/src/progress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function decode(message) {

function drill(o, callback) {
if (o && typeof o === "object") {
const copy = { ...o };
const copy = Array.isArray(o) ? [...o] : { ...o };
for (let k in copy) copy[k] = drill(copy[k], callback);
return copy;
} else return callback(o);
Expand Down
45 changes: 45 additions & 0 deletions src/renderer/src/stories/pages/guided-mode/SourceData.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import CellExplorerSortingInterfaceSchema from "../../../../../../schemas/json/g
import KiloSortSortingInterfaceSchema from "../../../../../../schemas/json/generated/KiloSortSortingInterface.json";
import Spike2RecordingInterfaceSchema from "../../../../../../schemas/json/generated/Spike2RecordingInterface.json";
import BrukerTiffSinglePlaneImagingInterfaceSchema from "../../../../../../schemas/json/generated/BrukerTiffSinglePlaneImagingInterface.json";
import BrukerTiffMultiPlaneImagingInterfaceSchema from "../../../../../../schemas/json/generated/BrukerTiffMultiPlaneImagingInterface.json";
import MicroManagerTiffImagingInterfaceSchema from "../../../../../../schemas/json/generated/MicroManagerTiffImagingInterface.json";
import ScanImageImagingInterfaceSchema from "../../../../../../schemas/json/generated/ScanImageImagingInterface.json";
import TiffImagingInterfaceSchema from "../../../../../../schemas/json/generated/TiffImagingInterface.json";
import MiniscopeImagingInterfaceSchema from "../../../../../../schemas/json/generated/MiniscopeImagingInterface.json";
import SbxImagingInterfaceSchema from "../../../../../../schemas/json/generated/SbxImagingInterface.json";

export default {
Expand Down Expand Up @@ -56,6 +61,16 @@ globalStateCopy.schema.source_data.properties.Spike2RecordingInterface =
Spike2RecordingInterfaceSchema.properties.Spike2RecordingInterface;
globalStateCopy.schema.source_data.properties.BrukerTiffSinglePlaneImagingInterface =
BrukerTiffSinglePlaneImagingInterfaceSchema.properties.BrukerTiffSinglePlaneImagingInterface;
globalStateCopy.schema.source_data.properties.BrukerTiffMultiPlaneImagingInterface =
BrukerTiffMultiPlaneImagingInterfaceSchema.properties.BrukerTiffMultiPlaneImagingInterface;
globalStateCopy.schema.source_data.properties.MicroManagerTiffImagingInterface =
MicroManagerTiffImagingInterfaceSchema.properties.MicroManagerTiffImagingInterface;
globalStateCopy.schema.source_data.properties.ScanImageImagingInterface =
ScanImageImagingInterfaceSchema.properties.ScanImageImagingInterface;
globalStateCopy.schema.source_data.properties.TiffImagingInterface =
TiffImagingInterfaceSchema.properties.TiffImagingInterface;
globalStateCopy.schema.source_data.properties.MiniscopeImagingInterface =
MiniscopeImagingInterfaceSchema.properties.MiniscopeImagingInterface;
globalStateCopy.schema.source_data.properties.SbxImagingInterface =
SbxImagingInterfaceSchema.properties.SbxImagingInterface;

Expand Down Expand Up @@ -161,6 +176,36 @@ BrukerTiffSinglePlaneImagingInterface.args = {
globalState: BrukerTiffSinglePlaneImagingInterfaceGlobalCopy,
};

export const BrukerTiffMultiPlaneImagingInterface = PageTemplate.bind({});
const BrukerTiffMultiPlaneImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
BrukerTiffMultiPlaneImagingInterfaceGlobalCopy.interfaces.interface = BrukerTiffMultiPlaneImagingInterface;
BrukerTiffMultiPlaneImagingInterfaceGlobalCopy.schema.source_data = BrukerTiffMultiPlaneImagingInterfaceSchema;
BrukerTiffMultiPlaneImagingInterface.args = { activePage, globalState: BrukerTiffMultiPlaneImagingInterfaceGlobalCopy };

export const MicroManagerTiffImagingInterface = PageTemplate.bind({});
const MicroManagerTiffImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
MicroManagerTiffImagingInterfaceGlobalCopy.interfaces.interface = MicroManagerTiffImagingInterface;
MicroManagerTiffImagingInterfaceGlobalCopy.schema.source_data = MicroManagerTiffImagingInterfaceSchema;
MicroManagerTiffImagingInterface.args = { activePage, globalState: MicroManagerTiffImagingInterfaceGlobalCopy };

export const ScanImageImagingInterface = PageTemplate.bind({});
const ScanImageImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
ScanImageImagingInterfaceGlobalCopy.interfaces.interface = ScanImageImagingInterface;
ScanImageImagingInterfaceGlobalCopy.schema.source_data = ScanImageImagingInterfaceSchema;
ScanImageImagingInterface.args = { activePage, globalState: ScanImageImagingInterfaceGlobalCopy };

export const TiffImagingInterface = PageTemplate.bind({});
const TiffImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
TiffImagingInterfaceGlobalCopy.interfaces.interface = TiffImagingInterface;
TiffImagingInterfaceGlobalCopy.schema.source_data = TiffImagingInterfaceSchema;
TiffImagingInterface.args = { activePage, globalState: TiffImagingInterfaceGlobalCopy };

export const MiniscopeImagingInterface = PageTemplate.bind({});
const MiniscopeImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
MiniscopeImagingInterfaceGlobalCopy.interfaces.interface = MiniscopeImagingInterface;
MiniscopeImagingInterfaceGlobalCopy.schema.source_data = MiniscopeImagingInterfaceSchema;
MiniscopeImagingInterface.args = { activePage, globalState: MiniscopeImagingInterfaceGlobalCopy };

export const SbxImagingInterface = PageTemplate.bind({});
const SbxImagingInterfaceGlobalCopy = JSON.parse(JSON.stringify(globalState));
SbxImagingInterfaceGlobalCopy.interfaces.interface = SbxImagingInterface;
Expand Down

0 comments on commit 2e2c430

Please sign in to comment.