use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class BaseZeissReader method fillMetadataPass6.
/**
* Read and store basic dimensions in model
* @param store
* @throws FormatException
* @throws IOException
*/
protected void fillMetadataPass6(MetadataStore store) throws FormatException, IOException {
CoreMetadata m = core.get(0);
if (getSizeX() == 0) {
m.sizeX = 1;
}
if (getSizeY() == 0) {
m.sizeY = 1;
}
if (bpp == 1 || bpp == 3)
m.pixelType = FormatTools.UINT8;
else if (bpp == 2 || bpp == 6)
m.pixelType = FormatTools.UINT16;
if (isJPEG)
m.pixelType = FormatTools.UINT8;
m.bitsPerPixel = FormatTools.getBytesPerPixel(m.pixelType) * 8;
m.indexed = !isRGB() && channelColors != null;
// it's filled.
for (int i = 1; i < core.size(); i++) {
core.set(i, new CoreMetadata(core.get(0)));
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class BioRadGelReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
String check = in.readString(48);
if (check.indexOf("Intel Format") != -1) {
in.order(true);
}
in.seek(START_OFFSET);
boolean codeFound = false;
int skip = 0;
long baseFP = 0;
while (!codeFound) {
short code = in.readShort();
if (code == 0x81)
codeFound = true;
short length = in.readShort();
in.skipBytes(2 + 2 * length);
if (codeFound) {
baseFP = in.getFilePointer() + 2;
if (length > 1) {
in.seek(in.getFilePointer() - 2);
}
skip = in.readInt() - 32;
} else {
if (length == 1)
in.skipBytes(12);
else if (length == 2)
in.skipBytes(10);
}
}
diff = BASE_OFFSET - baseFP;
skip += diff;
double physicalWidth = 0d, physicalHeight = 0d;
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
if (baseFP + skip - 8187 > 0) {
in.seek(baseFP + skip - 8187);
String scannerName = in.readCString();
in.skipBytes(8);
in.readCString();
in.skipBytes(8);
String imageArea = in.readCString();
imageArea = imageArea.substring(imageArea.indexOf(':') + 1).trim();
int xIndex = imageArea.indexOf('x');
if (xIndex > 0) {
int space = imageArea.indexOf(' ');
if (space >= 0) {
String width = imageArea.substring(1, space);
int nextSpace = imageArea.indexOf(" ", xIndex + 2);
if (nextSpace > xIndex) {
String height = imageArea.substring(xIndex + 1, nextSpace);
physicalWidth = Double.parseDouble(width.trim()) * 1000;
physicalHeight = Double.parseDouble(height.trim()) * 1000;
}
}
}
}
}
in.seek(baseFP + skip - 298);
String date = in.readString(17);
date = DateTools.formatDate(date, "dd-MMM-yyyy HH:mm");
in.skipBytes(73);
String scannerName = in.readCString();
addGlobalMeta("Scanner name", scannerName);
in.seek(baseFP + skip);
CoreMetadata m = core.get(0);
m.sizeX = in.readShort() & 0xffff;
m.sizeY = in.readShort() & 0xffff;
if (getSizeX() * getSizeY() > in.length()) {
in.order(true);
in.seek(in.getFilePointer() - 4);
m.sizeX = in.readShort();
m.sizeY = in.readShort();
}
in.skipBytes(2);
int bpp = in.readShort();
m.pixelType = FormatTools.pixelTypeFromBytes(bpp, false, false);
offset = in.getFilePointer();
m.sizeZ = 1;
m.sizeC = 1;
m.sizeT = 1;
m.imageCount = 1;
m.dimensionOrder = "XYCZT";
m.rgb = false;
m.interleaved = false;
m.indexed = false;
m.littleEndian = in.isLittleEndian();
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
if (date != null) {
store.setImageAcquisitionDate(new Timestamp(date), 0);
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
Length sizeX = FormatTools.getPhysicalSizeX(physicalWidth / getSizeX());
Length sizeY = FormatTools.getPhysicalSizeY(physicalHeight / getSizeY());
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class BioRadReader method readNotes.
// -- Helper methods --
/**
* Read all of the note strings from the given file. If the 'add' flag is
* set, the notes will be added to the 'noteStrings' list.
*/
private void readNotes(RandomAccessInputStream s, boolean add) throws IOException {
s.seek(70);
int imageLen = getSizeX() * getSizeY();
if (picFiles == null)
imageLen *= getImageCount();
else {
imageLen *= (getImageCount() / picFiles.length);
}
int bpp = FormatTools.getBytesPerPixel(getPixelType());
s.skipBytes(bpp * imageLen + 6);
boolean notes = true;
while (notes) {
if (s.getFilePointer() >= s.length()) {
brokenNotes = true;
break;
}
Note n = new Note();
n.level = s.readShort();
notes = s.readInt() != 0;
n.num = s.readShort();
n.status = s.readShort();
n.type = s.readShort();
n.x = s.readShort();
n.y = s.readShort();
n.p = s.readString(80);
if (n.type < 0 || n.type >= NOTE_NAMES.length) {
notes = false;
brokenNotes = true;
break;
}
if (!add)
continue;
// be sure to remove binary data from the note text
int ndx = n.p.length();
for (int i = 0; i < n.p.length(); i++) {
if (n.p.charAt(i) == 0) {
ndx = i;
break;
}
}
n.p = n.p.substring(0, ndx).trim();
String value = n.p.replaceAll("=", "");
final List<String> v = new ArrayList<String>();
StringTokenizer t = new StringTokenizer(value, " ");
while (t.hasMoreTokens()) {
String token = t.nextToken().trim();
if (token.length() > 0)
v.add(token);
}
String[] tokens = v.toArray(new String[v.size()]);
try {
if (tokens.length > 1) {
int noteType = Integer.parseInt(tokens[1]);
if (noteType == 2 && value.indexOf("AXIS_4") != -1) {
CoreMetadata m = core.get(0);
m.sizeZ = 1;
m.sizeT = getImageCount();
m.orderCertain = true;
}
}
} catch (NumberFormatException e) {
}
// add note to list
noteStrings.add(n);
}
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class BioRadReader method parseNotes.
private boolean parseNotes(MetadataStore store) throws FormatException {
boolean multipleFiles = false;
int nextDetector = 0, nLasers = 0;
for (Note n : noteStrings) {
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
switch(n.type) {
case NOTE_TYPE_USER:
// TODO : this should be an overlay
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_SCALEBAR:
// TODO : this should be an overlay
// the format of the text is:
// SCALEBAR = <length> <angle>
// where <length> is the length of the scalebar in microns,
// and <angle> is the angle in degrees
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_ARROW:
// TODO : this should be an overlay
// the format of the text is:
// ARROW = <lx> <ly> <angle> <fill>
// where <lx> and <ly> define the arrow's bounding box,
// <angle> is the angle in degrees and <fill> is either "Fill" or
// "Outline"
addGlobalMetaList("Note", n.toString());
break;
case NOTE_TYPE_VARIABLE:
if (n.p.indexOf('=') >= 0) {
String key = n.p.substring(0, n.p.indexOf('=')).trim();
String value = n.p.substring(n.p.indexOf('=') + 1).trim();
addGlobalMeta(key, value);
if (key.equals("INFO_OBJECTIVE_NAME")) {
store.setObjectiveModel(value, 0, 0);
} else if (key.equals("INFO_OBJECTIVE_MAGNIFICATION")) {
Double mag = Double.parseDouble(value);
store.setObjectiveNominalMagnification(mag, 0, 0);
} else if (key.equals("LENS_MAGNIFICATION")) {
Double magnification = Double.parseDouble(value);
store.setObjectiveNominalMagnification(magnification, 0, 0);
} else if (key.startsWith("SETTING")) {
if (key.indexOf("_DET_") != -1) {
int index = key.indexOf("_DET_") + 5;
if (key.lastIndexOf("_") > index) {
String detectorID = MetadataTools.createLSID("Detector", 0, nextDetector);
store.setDetectorID(detectorID, 0, nextDetector);
store.setDetectorType(getDetectorType("Other"), 0, nextDetector);
if (key.endsWith("OFFSET")) {
if (nextDetector < offset.size()) {
offset.set(nextDetector, Double.parseDouble(value));
} else {
while (nextDetector > offset.size()) {
offset.add(null);
}
offset.add(new Double(value));
}
} else if (key.endsWith("GAIN")) {
if (nextDetector < gain.size()) {
gain.set(nextDetector, Double.parseDouble(value));
} else {
while (nextDetector > gain.size()) {
gain.add(null);
}
gain.add(new Double(value));
}
}
nextDetector++;
}
}
} else {
String[] values = value.split(" ");
if (values.length > 1) {
try {
int type = Integer.parseInt(values[0]);
if (type == 257 && values.length >= 3) {
// found length of axis in um
Double pixelSize = new Double(values[2]);
if (key.equals("AXIS_2")) {
Length size = FormatTools.getPhysicalSizeX(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeX(size, 0);
}
} else if (key.equals("AXIS_3")) {
Length size = FormatTools.getPhysicalSizeY(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeY(size, 0);
}
}
}
} catch (NumberFormatException e) {
}
}
}
} else if (n.p.startsWith("AXIS_2")) {
String[] values = n.p.split(" ");
Double pixelSize = new Double(values[3]);
Length size = FormatTools.getPhysicalSizeX(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeX(size, 0);
}
} else if (n.p.startsWith("AXIS_3")) {
String[] values = n.p.split(" ");
Double pixelSize = new Double(values[3]);
Length size = FormatTools.getPhysicalSizeY(pixelSize);
if (size != null) {
store.setPixelsPhysicalSizeY(size, 0);
}
} else {
addGlobalMetaList("Note", n.toString());
}
break;
case NOTE_TYPE_STRUCTURE:
int structureType = (n.x & 0xff00) >> 8;
int version = (n.x & 0xff);
String[] values = n.p.split(" ");
if (structureType == 1) {
switch(n.y) {
case 1:
for (int i = 0; i < STRUCTURE_LABELS_1.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_1[i], values[i]);
}
Double mag = Double.parseDouble(values[11]);
store.setObjectiveNominalMagnification(mag, 0, 0);
Double sizeZ = new Double(values[14]);
Length size = FormatTools.getPhysicalSizeZ(sizeZ);
if (size != null) {
store.setPixelsPhysicalSizeZ(size, 0);
}
break;
case 2:
for (int i = 0; i < STRUCTURE_LABELS_2.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_2[i], values[i]);
}
double x1 = Double.parseDouble(values[2]);
double x2 = Double.parseDouble(values[4]);
double width = x2 - x1;
width /= getSizeX();
double y1 = Double.parseDouble(values[3]);
double y2 = Double.parseDouble(values[5]);
double height = y2 - y1;
height /= getSizeY();
Length sizeX = FormatTools.getPhysicalSizeX(width);
Length sizeY = FormatTools.getPhysicalSizeY(height);
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
break;
case 3:
for (int i = 0; i < 3; i++) {
for (int j = 0; j < STRUCTURE_LABELS_3.length; j++) {
String v = j == STRUCTURE_LABELS_3.length - 1 ? values[12 + i] : values[i * 4 + j];
addGlobalMetaList(STRUCTURE_LABELS_3[j], v);
}
}
break;
case 4:
nLasers = Integer.parseInt(values[0]);
addGlobalMeta("Number of lasers", values[0]);
addGlobalMeta("Number of transmission detectors", values[1]);
addGlobalMeta("Number of PMTs", values[2]);
for (int i = 1; i <= 3; i++) {
int idx = (i + 1) * 3;
addGlobalMetaList("Shutter present for laser", values[i + 2]);
addGlobalMetaList("Neutral density filter for laser", values[idx]);
addGlobalMetaList("Excitation filter for laser", values[idx + 1]);
addGlobalMetaList("Use laser", values[idx + 2]);
}
for (int i = 0; i < nLasers; i++) {
addGlobalMetaList("Neutral density filter name - laser", values[15 + i]);
}
break;
case 5:
String prefix = "Excitation filter name - laser";
for (int i = 0; i < nLasers; i++) {
addGlobalMetaList(prefix, values[i]);
}
break;
case 6:
prefix = "Emission filter name - laser";
for (int i = 0; i < nLasers; i++) {
addGlobalMeta(prefix, values[i]);
}
break;
case 7:
for (int i = 0; i < 2; i++) {
prefix = "Mixer " + i + " - ";
for (int j = 0; j < STRUCTURE_LABELS_4.length; j++) {
addGlobalMeta(prefix + STRUCTURE_LABELS_4[j], values[i * 7 + j]);
}
}
addGlobalMeta("Mixer 0 - low signal on", values[14]);
addGlobalMeta("Mixer 1 - low signal on", values[15]);
break;
case 8:
case 9:
case 10:
addGlobalMeta("Laser name - laser " + (n.y - 7), values[0]);
break;
case 11:
for (int i = 0; i < 3; i++) {
prefix = "Transmission detector " + (i + 1) + " - ";
addGlobalMeta(prefix + "offset", values[i * 3]);
addGlobalMeta(prefix + "gain", values[i * 3 + 1]);
addGlobalMeta(prefix + "black level", values[i * 3 + 2]);
String detectorID = MetadataTools.createLSID("Detector", 0, i);
store.setDetectorID(detectorID, 0, i);
store.setDetectorOffset(new Double(values[i * 3]), 0, i);
store.setDetectorGain(new Double(values[i * 3 + 1]), 0, i);
store.setDetectorType(getDetectorType("Other"), 0, i);
}
break;
case 12:
for (int i = 0; i < 2; i++) {
prefix = "Part number for ";
for (int j = 0; j < STRUCTURE_LABELS_5.length; j++) {
addGlobalMetaList(prefix + STRUCTURE_LABELS_5[j], values[i * 4 + j]);
}
}
break;
case 13:
for (int i = 0; i < STRUCTURE_LABELS_6.length; i++) {
addGlobalMeta(STRUCTURE_LABELS_6[i], values[i]);
}
break;
case 14:
prefix = "Filter Block Name - filter block ";
addGlobalMetaList(prefix, values[0]);
addGlobalMetaList(prefix, values[1]);
break;
case 15:
for (int i = 0; i < 5; i++) {
addGlobalMetaList("Image bands status - band", values[i * 3]);
addGlobalMetaList("Image bands min - band", values[i * 3 + 1]);
addGlobalMetaList("Image bands max - band", values[i * 3 + 2]);
if (store instanceof IMinMaxStore) {
((IMinMaxStore) store).setChannelGlobalMinMax(i, Double.parseDouble(values[i * 3 + 1]), Double.parseDouble(values[i * 3 + 2]), 0);
}
}
break;
case 17:
int year = Integer.parseInt(values[5]) + 1900;
for (int i = 0; i < 5; i++) {
if (values[i].length() == 1)
values[i] = "0" + values[i];
}
// date is in yyyy-MM-dd'T'HH:mm:ss
String date = year + "-" + values[4] + "-" + values[3] + "T" + values[2] + ":" + values[1] + ":" + values[0];
addGlobalMeta("Acquisition date", date);
try {
store.setImageAcquisitionDate(new Timestamp(date), 0);
} catch (Exception e) {
LOGGER.debug("Failed to parse acquisition date", e);
}
break;
case 18:
addGlobalMeta("Mixer 3 - enhanced", values[0]);
for (int i = 1; i <= 3; i++) {
addGlobalMetaList("Mixer 3 - PMT percentage", values[i]);
addGlobalMetaList("Mixer 3 - Transmission percentage", values[i + 3]);
addGlobalMetaList("Mixer 3 - photon counting", values[i + 7]);
}
addGlobalMeta("Mixer 3 - low signal on", values[7]);
addGlobalMeta("Mixer 3 - mode", values[11]);
break;
case 19:
for (int i = 1; i <= 2; i++) {
prefix = "Mixer " + i + " - ";
String photon = prefix + "photon counting ";
addGlobalMetaList(photon, values[i * 4 - 4]);
addGlobalMetaList(photon, values[i * 4 - 3]);
addGlobalMetaList(photon, values[i * 4 - 2]);
addGlobalMeta(prefix + "mode", values[i * 4 - 1]);
}
break;
case 20:
addGlobalMeta("Display mode", values[0]);
addGlobalMeta("Course", values[1]);
addGlobalMeta("Time Course - experiment type", values[2]);
addGlobalMeta("Time Course - kd factor", values[3]);
String experimentID = MetadataTools.createLSID("Experiment", 0);
store.setExperimentID(experimentID, 0);
store.setExperimentType(getExperimentType(values[2]), 0);
break;
case 21:
addGlobalMeta("Time Course - ion name", values[0]);
break;
case 22:
addGlobalMeta("PIC file generated on Isoscan (lite)", values[0]);
for (int i = 1; i <= 3; i++) {
addGlobalMetaList("Photon counting used - PMT", values[i]);
addGlobalMetaList("Hot spot filter used - PMT", values[i + 3]);
addGlobalMetaList("Tx Selector used - TX", values[i + 6]);
}
break;
}
}
break;
default:
// notes for display only
addGlobalMetaList("Note", n.toString());
}
}
if (n.p.indexOf("AXIS") != -1) {
n.p = n.p.replaceAll("=", "");
final List<String> v = new ArrayList<String>();
StringTokenizer tokens = new StringTokenizer(n.p, " ");
while (tokens.hasMoreTokens()) {
String token = tokens.nextToken().trim();
if (token.length() > 0)
v.add(token);
}
String[] values = v.toArray(new String[v.size()]);
String key = values[0];
String noteType = values[1];
int axisType = Integer.parseInt(noteType);
if (axisType == 11 && values.length > 2) {
addGlobalMeta(key + " RGB type (X)", values[2]);
addGlobalMeta(key + " RGB type (Y)", values[3]);
CoreMetadata m = core.get(0);
if (key.equals("AXIS_4")) {
// this is a single section multi-channel dataset
m.sizeC = getImageCount();
m.sizeZ = 1;
m.sizeT = 1;
} else if (key.equals("AXIS_9")) {
multipleFiles = true;
m.sizeC = (int) Double.parseDouble(values[3]);
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM && values.length > 2) {
switch(axisType) {
case 1:
addGlobalMeta(key + " distance (X) in microns", values[2]);
addGlobalMeta(key + " distance (Y) in microns", values[3]);
break;
case 3:
addGlobalMeta(key + " angle (X) in degrees", values[2]);
addGlobalMeta(key + " angle (Y) in degrees", values[3]);
break;
case 4:
addGlobalMeta(key + " intensity (X)", values[2]);
addGlobalMeta(key + " intensity (Y)", values[3]);
break;
case 6:
addGlobalMeta(key + " ratio (X)", values[2]);
addGlobalMeta(key + " ratio (Y)", values[3]);
break;
case 7:
addGlobalMeta(key + " log ratio (X)", values[2]);
addGlobalMeta(key + " log ratio (Y)", values[3]);
break;
case 9:
addGlobalMeta(key + " noncalibrated intensity min", values[2]);
addGlobalMeta(key + " noncalibrated intensity max", values[3]);
addGlobalMeta(key + " calibrated intensity min", values[4]);
addGlobalMeta(key + " calibrated intensity max", values[5]);
break;
case 14:
addGlobalMeta(key + " time course type (X)", values[2]);
addGlobalMeta(key + " time course type (Y)", values[3]);
break;
case 15:
String prefix = " inverse sigmoid calibrated intensity ";
addGlobalMeta(key + prefix + "(min)", values[2]);
addGlobalMeta(key + prefix + "(max)", values[3]);
addGlobalMeta(key + prefix + "(beta)", values[4]);
addGlobalMeta(key + prefix + "(Kd)", values[5]);
break;
case 16:
prefix = " log inverse sigmoid calibrated intensity ";
addGlobalMeta(key + prefix + "(min)", values[2]);
addGlobalMeta(key + prefix + "(max)", values[3]);
addGlobalMeta(key + prefix + "(beta)", values[4]);
addGlobalMeta(key + prefix + "(Kd)", values[5]);
break;
}
}
}
}
return multipleFiles;
}
use of loci.formats.CoreMetadata in project bioformats by openmicroscopy.
the class BioRadSCNReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
CoreMetadata m = core.get(0);
String line = in.readLine();
String currentBoundary = "";
String currentType = "";
int currentLength = 0;
ArrayList<String> xml = new ArrayList<String>();
while (in.getFilePointer() < in.length() && line != null) {
line = line.trim();
if (line.startsWith("Content-Type")) {
currentType = line.substring(line.indexOf(' ') + 1);
int boundary = currentType.indexOf("boundary");
if (boundary > 0) {
currentBoundary = currentType.substring(boundary + 10, currentType.length() - 1);
}
if (currentType.indexOf(';') > 0) {
currentType = currentType.substring(0, currentType.indexOf(';'));
}
} else if (line.equals("--" + currentBoundary)) {
currentLength = 0;
} else if (line.startsWith("Content-Length")) {
currentLength = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
} else if (line.length() == 0) {
if (currentType.equals("application/octet-stream")) {
pixelsOffset = in.getFilePointer();
in.skipBytes(currentLength);
} else if (currentType.equals("text/xml")) {
String xmlBlock = in.readString(currentLength);
xml.add(xmlBlock);
}
}
line = in.readLine();
}
SCNHandler handler = new SCNHandler();
for (String block : xml) {
XMLTools.parseXML(block, handler);
}
m.sizeZ = 1;
m.sizeT = 1;
m.imageCount = 1;
m.dimensionOrder = "XYCZT";
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this, exposureTime != null);
store.setInstrumentID(MetadataTools.createLSID("Instrument", 0), 0);
if (serialNumber != null) {
store.setMicroscopeSerialNumber(serialNumber, 0);
}
if (model != null) {
store.setMicroscopeModel(model, 0);
}
if (imageName != null) {
store.setImageName(imageName, 0);
}
if (acquisitionDate != null) {
store.setImageAcquisitionDate(new Timestamp(acquisitionDate), 0);
}
if (gain != null || binning != null) {
String detector = MetadataTools.createLSID("Detector", 0, 0);
store.setDetectorID(detector, 0, 0);
store.setDetectorSettingsID(detector, 0, 0);
}
if (gain != null) {
store.setDetectorSettingsGain(gain, 0, 0);
}
if (binning != null) {
store.setDetectorSettingsBinning(getBinning(binning), 0, 0);
}
if (exposureTime != null) {
store.setPlaneExposureTime(new Time(exposureTime, UNITS.SECOND), 0, 0);
}
if (physicalSizeX != null) {
store.setPixelsPhysicalSizeX(FormatTools.createLength(physicalSizeX, UNITS.MICROMETER), 0);
}
if (physicalSizeY != null) {
store.setPixelsPhysicalSizeY(FormatTools.createLength(physicalSizeY, UNITS.MICROMETER), 0);
}
}
Aggregations