### Setting up LibreOffice SDK Environment on Unix-like Systems Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This command initializes the LibreOffice SDK environment on Unix-based systems like macOS. It's typically run from the SDK's installation directory and prepares the shell with necessary paths and variables. It might prompt for configuration details the first time it's executed. ```bash $ sh setsdkenv_unix ``` -------------------------------- ### Launch LibreOffice with SDK Support Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This section describes how to start LibreOffice with SDK support using a specific socket connection. It's a prerequisite for running the odt2pdf tool. Ensure `soffice` is in your PATH. The command attempts to bind to a local socket for inter-process communication. ```bash $ which soffice /Applications/LibreOffice.app/Contents/MacOS/soffice $ soffice "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" & ``` -------------------------------- ### Standard Tool Compilation Command (Illustrative) Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This snippet shows a typical command sequence for building a tool. It involves changing the directory to the tool's source, creating a C++ source file (if it doesn't exist), and then running the `make` command. This is presented as a non-working example for macOS 10.14 due to specific library loading issues. ```bash $ cd path/to/odt2pdf $ touch odt2pdf.cxx $ make ``` -------------------------------- ### 3D Volume Rendering with VRController in Objective-C Source: https://context7.com/bettar/miele-lxiv/llms.txt Provides examples of creating 3D visualizations including volume rendering, MIP, and MPR from CT/MRI series using the VRController. It covers loading volumetric data, setting rendering modes, adjusting window/level, applying color and opacity transfer functions, and handling 4D datasets by navigating through time frames. The code also demonstrates computing ROI volumes. ```objective-c // Load volumetric series NSMutableArray *pixList = /* array of DCMPix objects */; NSArray *fileList = /* corresponding file paths */; ViewerController *viewer2D = /* reference to 2D viewer */; // Create volume rendering controller VRController *vrController = [[VRController alloc] initWithPix:pixList :fileList :nil // volume data :viewer2D :nil style:@"standard" mode:@"VR"]; // Set rendering mode [vrController setRenderingMode:@"VR"]; // Volume Rendering // Other modes: @"MIP", @"MinIP", @"STOCHASTICMIP" // Adjust window/level [vrController setWLWW:300 :600]; // Apply preset color/opacity transfer function [vrController ApplyCLUTString:@"Bones"]; // Built-in presets [vrController ApplyOpacityString:@"Bones"]; // Custom CLUT example NSString *clutString = @"0 0 0 0 100 255 0 0 200 255 255 0 255 255 255 255"; [vrController ApplyCLUTString:clutString]; // For 4D datasets (e.g., cardiac CT) if ([vrController is4D]) { long totalFrames = [vrController movieFrames]; NSLog(@"4D dataset with %ld frames", totalFrames); // Navigate through time frames for (long frame = 0; frame < totalFrames; frame++) { [vrController setMovieFrame:frame]; [NSThread sleepForTimeInterval:0.1]; } } // Compute 3D ROI volumes NSMutableArray *roiVolumes = [vrController roiVolumes]; [vrController computeROIVolumes]; ``` -------------------------------- ### Access and Process ROI Data via OSI Framework (Objective-C) Source: https://context7.com/bettar/miele-lxiv/llms.txt This code demonstrates how to access and process Region of Interest (ROI) data within a plugin using the OSI framework. It shows how to retrieve ROIs, get their properties like name and color, calculate volume and center of mass, extract intensity statistics, and obtain convex hull and mask data. Dependencies include the OSI framework, specifically OSIROIManager, OSIROI, OSIFloatVolumeData, and OSIROIMask. It takes a viewer controller and ROI objects as input and outputs processed ROI data. ```objective-c // From within a plugin using OSI framework OSIROIManager *roiManager = [viewerController ROIManager]; NSArray *allROIs = [roiManager ROIs]; for (OSIROI *roi in allROIs) { // Get ROI properties NSString *name = [roi name]; NSColor *color = [roi fillColor]; NSLog(@"Processing ROI: %@", name); // Calculate volume CGFloat volume = [roi volume]; // in mm³ NSLog(@"Volume: %.2f mm³ (%.2f mL)", volume, volume / 1000.0); // Get center of mass N3Vector centerOfMass = [roi centerOfMass]; NSLog(@"Center: (%.2f, %.2f, %.2f)", centerOfMass.x, centerOfMass.y, centerOfMass.z); // Calculate intensity statistics OSIFloatVolumeData *volumeData = [viewerController floatVolumeDataForDimensionsAndIndexes:...]; CGFloat meanIntensity = [roi intensityMeanWithFloatVolumeData:volumeData]; // Get all available metrics NSArray *metricNames = [roi metricNames]; for (NSString *metric in metricNames) { id value = [roi valueForMetric:metric floatVolumeData:volumeData]; NSLog(@"%@: %@", metric, value); } // Get convex hull NSArray *hullPoints = [roi convexHull]; // Array of N3Vectors NSLog(@"Convex hull has %lu vertices", (unsigned long)[hullPoints count]); // Get ROI mask OSIROIMask *mask = [roi ROIMaskForFloatVolumeData:volumeData]; // Get pixel data within ROI OSIROIFloatPixelData *pixelData = [roi ROIFloatPixelDataForFloatVolumeData:volumeData]; const float *data = [pixelData floatBytes]; NSUInteger count = [pixelData floatBytesCount] / sizeof(float); // Calculate custom statistics float sum = 0, max = -FLT_MAX; for (NSUInteger i = 0; i < count; i++) { sum += data[i]; if (data[i] > max) max = data[i]; } float mean = sum / count; NSLog(@"Custom stats - Mean: %.2f, Max: %.2f", mean, max); } ``` -------------------------------- ### JavaScript Flash Player Detection Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/series.html This JavaScript snippet checks if the Adobe Flash Player is installed in the user's browser. If Flash is detected, it hides a warning element. It also includes commented-out code for potentially preventing page scrolling when interacting with a Flash video. ```javascript if (FlashDetect.installed) { $("#flashwarning").hide(); } /* $('#flashobject').bind('mousewheel', function(e,d) { // this is an attempt to stop the page from scrolling when scrolling the flash video e.stopImmediatePropagation(); e.stopPropagation(); e.preventDefault(); return false; }); */ ``` -------------------------------- ### Compiling a Tool with LibreOffice SDK on macOS 10.14 Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This sequence of commands is a workaround for build issues on macOS 10.14 when compiling with the LibreOffice SDK. It involves creating a fake bin directory, copying essential binaries, and then using these fakes to initialize the SDK environment and run the make command. This ensures the build process uses the correct shell and paths. ```bash $ mkdir ~/fakebin $ cp /bin/bash /usr/bin/make ~/fakebin $ SHELL=~/fakebin/bash ~/Downloads/LibreOffice6.3_SDK/setsdkenv_unix $ cd path/to/odt2pdf $ ~/fakebin/make SHELL="$SHELL" ``` -------------------------------- ### Execute odt2pdf Conversion Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This snippet shows how to execute the `odt2pdf` command after LibreOffice has been launched with SDK support. It specifies the input `.odt` file and the desired output `.pdf` file, along with environment variables required for the tool to find necessary components. ```bash $ odt2pdf -env:URE_MORE_TYPES=file:///Applications/LibreOffice.app/Contents/Resources/types/offapi.rdb path/to/test.odt path/to/output.pdf ``` -------------------------------- ### Run odt2pdf on Older macOS with SDK Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This sequence demonstrates running `odt2pdf` on an older macOS version (10.6.8). It involves changing the directory to where files are located, setting the `DYLD_LIBRARY_PATH`, launching LibreOffice with socket acceptance, and then executing the `odt2pdf` conversion command. ```bash $ cd ~/Desktop $ export DYLD_LIBRARY_PATH=/Applications/LibreOffice.app/Contents/MacOS/urelibs $ soffice "--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" & $ ./odt2pdf -env:URE_MORE_TYPES=file:///Applications/LibreOffice.app/Contents/basis-link/program/offapi.rdb test.odt test.pdf ``` -------------------------------- ### Set DYLD_LIBRARY_PATH for odt2pdf Execution Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md This command exports the `DYLD_LIBRARY_PATH` environment variable, which is necessary for `odt2pdf` to locate required shared libraries when running without the SDK directly. This is particularly useful when deploying the tool on client machines. ```bash $ export DYLD_LIBRARY_PATH=/Applications/LibreOffice.app/Contents/MacOS/urelibs ``` -------------------------------- ### Quit LibreOffice Process Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/ReportsToPDF/odt2pdf/readme.md A command to forcefully terminate any running LibreOffice processes, identified by the `soffice` executable name. This is useful for cleanup or restarting the service. ```bash $ killall soffice ``` -------------------------------- ### JavaScript Image Display Overlay Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/study.html The `imageClick` function creates and displays an image overlay when an image is clicked. It generates a `div` element with an ID 'overlay' and appends it to the document body. This overlay contains an image that links to a series, and a 'Close' option to remove the overlay. ```javascript function imageClick(ixid, sxid) { var div = document.createElement("div"); div.id = "overlay"; div.onclick = function() { document.body.removeChild(this); }; div.innerHTML = "
"; document.body.appendChild(div); } ``` -------------------------------- ### Writing DICOM Files Source: https://context7.com/bettar/miele-lxiv/llms.txt This section explains how to create and write DICOM files, including applying different compression methods like JPEG 2000 and uncompressed formats. ```APIDOC ## Writing DICOM Files ### Description This endpoint group allows for creating and writing DICOM files, with support for various compression techniques including JPEG 2000, JPEG lossy/lossless, and uncompressed formats. ### Method `[Objective-C]` ### Endpoint N/A (Instance method on `DCMObject`) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A (Operates on an existing `DCMObject` instance) ### Request Example ```objective-c // Read existing DICOM file DCMObject *object = [[DCMObject alloc] initWithContentsOfFile:@"/input/file.dcm" decodingPixelData:NO]; // Modify attributes DCMAttribute *name = [object attributeForTag:[DCMAttributeTag tagWithName:@"PatientsName"]]; [name setValues:[NSMutableArray arrayWithObject:@"Doe^John"]]; DCMAttribute *patientID = [object attributeForTag:[DCMAttributeTag tagWithName:@"PatientID"]]; [patientID setValues:[NSMutableArray arrayWithObject:@"12345"]]; // Generate new SOP Instance UID [object newSOPInstanceUID]; // Write with JPEG 2000 compression NSString *outputPath = @"/output/compressed.dcm"; BOOL success = [object writeToFile:outputPath withTransferSyntax:[DCMTransferSyntax JPEG2000LossyTransferSyntax] quality:DCMHighQuality AET:@"MIELE_LXIV" atomically:YES]; // Alternative: Write uncompressed [object writeToFile:outputPath withTransferSyntax:[DCMTransferSyntax ExplicitVRLittleEndianTransferSyntax] quality:0 AET:@"MIELE_LXIV" atomically:YES]; ``` ### Response #### Success Response (200) - **success** (BOOL) - Returns `YES` if the file was written successfully, `NO` otherwise. #### Response Example (Objective-C console output) ``` (No direct output, success is a boolean return value) ``` ``` -------------------------------- ### JavaScript Login Action for Password Hashing Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/account.html This JavaScript function, `loginAction`, is designed to hash the user's current password using SHA1 before submission. It takes a form element as input, calculates the SHA1 hash of the previous password concatenated with the username, updates the form's SHA1 field, and clears the previous password field. It relies on a `hex_sha1` function (not provided here) for the hashing process. ```javascript function loginAction(form) { form.sha1.value = hex_sha1(form.previouspassword.value+'%X:User.name%'); form.previouspassword.value = ''; return true; } ``` -------------------------------- ### Manage DICOM Database Operations (Objective-C) Source: https://context7.com/bettar/miele-lxiv/llms.txt This code snippet demonstrates how to interact with the DICOM database, including importing files, finding studies and series by UID, and opening them in a viewer. It utilizes the BrowserController and DicomDatabase classes. Dependencies include the BrowserController, DicomDatabase, and ViewerController classes. It takes file paths and UIDs as input and outputs imported object counts, study/patient details, and viewer instances. ```objective-c // Get main database instance BrowserController *browser = [BrowserController currentBrowser]; DicomDatabase *database = browser.database; // Import DICOM files into database NSArray *newFiles = @[@"/path/to/import/file1.dcm", @"/path/to/import/file2.dcm"]; NSArray *addedObjects = [browser addFilesToDatabase:newFiles]; NSLog(@"Imported %lu DICOM objects", (unsigned long)[addedObjects count]); // Refresh database to show new files [browser refreshDatabase:nil]; // Find study by UID NSString *studyUID = @"1.2.840.113619.2.55.3.12345678.987"; NSManagedObject *study = [browser findStudyUID:studyUID]; if (study) { NSLog(@"Found study: %@", [study valueForKey:@"studyName"]); NSLog(@"Patient: %@", [[study valueForKey:@"patient"] valueForKey:@"name"]); NSLog(@"Date: %@", [study valueForKey:@"date"]); } // Find series by UID NSString *seriesUID = @"1.2.840.113619.2.55.3.12345678.987.1"; NSManagedObject *series = [browser findSeriesUID:seriesUID]; // Open series in viewer ViewerController *viewerController = [browser loadSeries: series :nil :YES keyImagesOnly:NO]; // Open specific images NSArray *imagesToOpen = /* array of DicomImage NSManagedObjects */; ViewerController *viewer = [browser openViewerFromImages: imagesToOpen movie:NO viewer:nil keyImagesOnly:NO]; // Get current database selection NSArray *selectedObjects = [browser databaseSelection]; for (NSManagedObject *obj in selectedObjects) { if ([[obj entity].name isEqualToString:@"Study"]) { NSLog(@"Selected study: %@", [obj valueForKey:@"studyName"]); } } ``` -------------------------------- ### Create and Measure Regions of Interest (ROIs) (Objective-C) Source: https://context7.com/bettar/miele-lxiv/llms.txt Demonstrates the creation of various ROI shapes including rectangular, oval, and polygonal ROIs. It also shows how to compute statistical measurements (mean, total, standard deviation, min, max) for a given ROI, calculate its area in cm², and measure the length of a line ROI. Requires DCMPix and ROI classes. ```objective-c // Create rectangular ROI ROI *rectROI = [[ROI alloc] initWithType:tROI :[[NSMutableArray alloc] init] :dcmPix]; rectROI.rect = NSMakeRect(100, 100, 50, 50); // x, y, width, height [rectROI.name setString:@"Liver ROI"]; rectROI.rgbcolor = RGBColorMake(255, 0, 0); // Red color rectROI.thickness = 2.0; // Create circular/oval ROI ROI *ovalROI = [[ROI alloc] initWithType:tOval :[[NSMutableArray alloc] init] :dcmPix]; ovalROI.rect = NSMakeRect(200, 200, 60, 60); // Create polygon ROI with points NSMutableArray *points = [NSMutableArray array]; [points addObject:[NSValue valueWithPoint:NSMakePoint(150, 150)]]; [points addObject:[NSValue valueWithPoint:NSMakePoint(200, 150)]]; [points addObject:[NSValue valueWithPoint:NSMakePoint(200, 200)]]; [points addObject:[NSValue valueWithPoint:NSMakePoint(150, 200)]]; ROI *polygonROI = [[ROI alloc] initWithType:tClosedPolygon :points :dcmPix]; // Calculate ROI statistics float mean, total, dev, minVal, maxVal; [dcmPix computeROI:rectROI :&mean :&total :&dev :&minVal :&maxVal]; NSLog(@"ROI Stats - Mean: %.2f, StdDev: %.2f, Min: %.2f, Max: %.2f", mean, dev, minVal, maxVal); // Get ROI area in cm² float areaCm2 = [rectROI roiArea]; NSLog(@"ROI Area: %.2f cm²", areaCm2); // Measure length for line ROI ROI *lineROI = [[ROI alloc] initWithType:tMeasure :[[NSMutableArray alloc] init] :dcmPix]; float lengthPixels; float lengthCm = [lineROI MeasureLength:&lengthPixels]; NSLog(@"Length: %.2f cm (%.0f pixels)", lengthCm, lengthPixels); ``` -------------------------------- ### DICOM File Upload Handling (JavaScript) Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/main.html This JavaScript code handles the selection and uploading of DICOM files. It includes functions to display file details, manage the upload process with progress indication, and handle completion or failure events. It relies on the browser's XMLHttpRequest and FormData objects for asynchronous file transfer. ```javascript function fileSelected() { var file = document.getElementById('fileToUpload').files[0]; if (file) { var fileSize = 0; if (file.size > 1024 * 1024) fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; else fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB'; document.getElementById('fileName').innerHTML = 'Name: ' + file.name; document.getElementById('fileSize').innerHTML = 'Size: ' + fileSize; document.getElementById('fileType').innerHTML = 'Type: ' + file.type; document.getElementById('upload').style.display = 'block'; } } function uploadFile() { var fd = new FormData(); fd.append("fileToUpload", document.getElementById('fileToUpload').files[0]); var xhr = new XMLHttpRequest(); xhr.upload.addEventListener("progress", uploadProgress, false); xhr.addEventListener("load", uploadComplete, false); xhr.addEventListener("error", uploadFailed, false); xhr.addEventListener("abort", uploadCanceled, false); xhr.open("POST", "", true); xhr.send(fd); document.getElementById('upload').style.display = 'none'; } function uploadProgress(evt) { if (evt.lengthComputable) { var percentComplete = Math.round(evt.loaded * 100 / evt.total); if (percentComplete == 100) document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '% - Importing data... Please wait.'; else document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '% - Uploading... Please wait.'; } else { document.getElementById('progressNumber').innerHTML = 'Unable to compute'; } } function uploadComplete(evt) { document.getElementById('progressNumber').innerHTML = 'Upload completed !'; document.getElementById('upload').style.display = 'block'; } function uploadFailed(evt) { document.getElementById('upload').style.display = 'block'; alert("There was an error attempting to upload the file."); } function uploadCanceled(evt) { document.getElementById('upload').style.display = 'block'; alert("The upload has been canceled by the user or the browser dropped the connection."); } ``` -------------------------------- ### Write DICOM Files with Compression Options Source: https://context7.com/bettar/miele-lxiv/llms.txt Illustrates how to create and write DICOM files using the DCMObject class, supporting various compression methods like JPEG 2000 (lossy and lossless), JPEG (lossy/lossless), and uncompressed formats. This is essential for DICOM data storage and transmission. ```objective-c // Read existing DICOM file DCMObject *object = [[DCMObject alloc] initWithContentsOfFile:@"/input/file.dcm" decodingPixelData:NO]; // Modify attributes DCMAttribute *name = [object attributeForTag:[DCMAttributeTag tagWithName:@"PatientsName"]]; [name setValues:[NSMutableArray arrayWithObject:@"Doe^John"]]; DCMAttribute *patientID = [object attributeForTag:[DCMAttributeTag tagWithName:@"PatientID"]]; [patientID setValues:[NSMutableArray arrayWithObject:@"12345"]]; // Generate new SOP Instance UID [object newSOPInstanceUID]; // Write with JPEG 2000 compression NSString *outputPath = @"/output/compressed.dcm"; BOOL success = [object writeToFile:outputPath withTransferSyntax:[DCMTransferSyntax JPEG2000LossyTransferSyntax] quality:DCMHighQuality AET:@"MIELE_LXIV" atomically:YES]; // Alternative: Write uncompressed [object writeToFile:outputPath withTransferSyntax:[DCMTransferSyntax ExplicitVRLittleEndianTransferSyntax] quality:0 AET:@"MIELE_LXIV" atomically:YES]; ``` -------------------------------- ### DICOM Send (C-STORE SCU) Implementation Source: https://context7.com/bettar/miele-lxiv/llms.txt Shows how to send DICOM files to a remote PACS server or workstation using the C-STORE service class (SCU). It details the configuration of connection parameters such as calling and called AETs, hostname, port, and transfer syntax, along with specifying the files to send. ```objective-c // Prepare file list NSArray *filesToSend = @[@"/path/to/file1.dcm", @"/path/to/file2.dcm", @"/path/to/file3.dcm"]; // Configure connection parameters NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:@"MIELE_LXIV" forKey:@"callingAET"]; [params setObject:@"REMOTE_PACS" forKey:@"calledAET"]; [params setObject:@"192.168.1.100" forKey:@"hostname"]; [params setObject:@"11112" forKey:@"port"]; [params setObject:[DCMTransferSyntax ExplicitVRLittleEndianTransferSyntax] forKey:@"transferSyntax"]; [params setObject:filesToSend forKey:@"filesToSend"]; [params setObject:[NSNumber numberWithInt:1] forKey:@"debugLevel"]; // Send files BOOL result = [DCMStoreSCU sendWithParameters:params]; if (result) { NSLog(@"Successfully sent %lu files", (unsigned long)[filesToSend count]); } else { NSLog(@"Failed to send files"); } ``` -------------------------------- ### Display DICOM Images with DCMView in Objective-C Source: https://context7.com/bettar/miele-lxiv/llms.txt Demonstrates loading and displaying DICOM image series using the DCMView class. It covers loading image files, setting them to the view, adjusting window/level, scaling, zooming, panning, rotating, navigating slices, and applying color lookup tables. The code assumes an instance of DCMView is available and handles the manipulation of individual DICOM pixels (DCMPix). ```objective-c // Assume we have a DCMView instance from Interface Builder DCMView *imageView = self.dcmView; // Load image series NSMutableArray *pixList = [NSMutableArray array]; NSArray *fileList = @[@"/path/to/slice1.dcm", @"/path/to/slice2.dcm", @"/path/to/slice3.dcm"]; for (NSString *path in fileList) { DCMPix *pix = [[DCMPix alloc] initWithPath:path :0 :1 :nil :0 :0 isBonjour:NO imageObj:nil]; [pixList addObject:pix]; } // Set images to view [imageView setPixels:pixList files:fileList rois:[[NSMutableArray alloc] init] firstImage:0 level:'i' reset:YES]; // Set window/level for CT brain [imageView setWLWW:40 :80]; // WL=40, WW=80 // Scale to fit window [imageView scaleToFit]; // Manual zoom and panimageView.scaleValue = 2.0; // 2x zoom imageView.origin = NSMakePoint(100, 100); // Rotate image 90 degrees imageView.rotation = 90.0; // Navigate to specific slice [imageView setIndex:5]; // Apply color lookup table unsigned char red[256], green[256], blue[256]; // Fill CLUT arrays (e.g., for PET hot metal scale) for (int i = 0; i < 256; i++) { red[i] = i; green[i] = i < 128 ? 0 : (i - 128) * 2; blue[i] = i < 192 ? 0 : (i - 192) * 4; } [imageView setCLUT:red :green :blue]; // Export current view as NSImage NSImage *snapshot = [imageView nsimage]; ``` -------------------------------- ### JavaScript Form Submission Handling Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/study.html This JavaScript function `onSubmitForm` handles the form submission process. It dynamically sets the form's action URL based on a 'Weasis' flag or the current document location. It also clears the 'message' field if its value is the default. ```javascript function onSubmitForm(form) { if (document.submitting == 'Weasis') form.action ="%X:Study.name%-weasis.jnlp"; else form.action = document.location; if( form.message) { if (form.message.value == form.message.defaultValue) form.message.value = ''; } return true; } ``` -------------------------------- ### JavaScript Login Action and Form Handling Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/login.pvt.html This JavaScript function calculates the SHA1 hash of the concatenated username and password, updates the form, clears the password field, and returns true to allow form submission. It is designed to be used within an HTML form for user authentication. ```javascript function loginAction(form) { form.sha1.value = hex_sha1(form.password.value+form.username.value); form.password.value = ''; return true; } ``` -------------------------------- ### DICOM C-FIND Query for Studies using Objective-C Source: https://context7.com/bettar/miele-lxiv/llms.txt This snippet demonstrates how to perform a DICOM C-FIND query at the STUDY level to retrieve information about patients and their studies from a remote PACS server. It requires a DCMObject for the query and a dictionary for connection parameters, including AETs, hostname, and port. The output is an array of DCMObject results. ```objective-c // Create query object at STUDY level DCMObject *findObject = [DCMObject dcmObject]; [findObject setAttributeValues:[NSMutableArray arrayWithObject:@"DOE*"] forKey:@"PatientsName"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"PatientID"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"StudyDescription"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"StudyInstanceUID"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"AccessionNumber"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"StudyDate"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"StudyTime"]; [findObject setAttributeValues:[NSMutableArray array] forKey:@"ModalitiesInStudy"]; [findObject setAttributeValues:[NSMutableArray arrayWithObject:@"STUDY"] forKey:@"Query/RetrieveLevel"]; // Configure connection NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:@"MIELE_LXIV" forKey:@"callingAET"]; [params setObject:@"REMOTE_PACS" forKey:@"calledAET"]; [params setObject:@"192.168.1.100" forKey:@"hostname"]; [params setObject:@"11112" forKey:@"port"]; [params setObject:findObject forKey:@"findObject"]; [params setObject:[DCMAbstractSyntaxUID studyRootQueryRetrieveInformationModelFind] forKey:@"affectedSOPClassUID"]; [params setObject:[NSNumber numberWithInt:1] forKey:@"debugLevel"]; // Execute query - results returned in array NSArray *results = [DCMFindSCU findWithParameters:params]; for (DCMObject *result in results) { NSLog(@"Patient: %@, Study: %@, Date: %@", [result attributeValueWithName:@"PatientsName"], [result attributeValueWithName:@"StudyDescription"], [result attributeValueWithName:@"StudyDate"]); } ``` -------------------------------- ### Access DICOM Image Pixel Data and Spatial Info (Objective-C) Source: https://context7.com/bettar/miele-lxiv/llms.txt Loads a DICOM image file, retrieves pixel dimensions, spacing, slice information, and raw pixel data. It calculates basic image statistics (mean, min, max) and demonstrates adjusting window/level settings and converting pixel coordinates to DICOM coordinates. Requires the DCMPix class. ```objective-c // Load DICOM image NSString *path = @"/path/to/image.dcm"; DCMPix *dcmPix = [[DCMPix alloc] initWithPath:path :0 // position :1 // total :nil // pixel buffer :0 // frame :0 // series isBonjour:NO imageObj:nil]; // Access pixel dimensions and spacing NSLog(@"Image size: %ld x %ld", dcmPix.pwidth, dcmPix.pheight); NSLog(@"Pixel spacing: %.2f x %.2f mm", dcmPix.pixelSpacingX, dcmPix.pixelSpacingY); NSLog(@"Slice location: %.2f mm", dcmPix.sliceLocation); NSLog(@"Slice thickness: %.2f mm", dcmPix.sliceThickness); // Access raw pixel data as float array float *pixels = dcmPix.fImage; long totalPixels = dcmPix.pwidth * dcmPix.pheight; // Calculate image statistics float sum = 0, minVal = FLT_MAX, maxVal = -FLT_MAX; for (long i = 0; i < totalPixels; i++) { sum += pixels[i]; if (pixels[i] < minVal) minVal = pixels[i]; if (pixels[i] > maxVal) maxVal = pixels[i]; } float mean = sum / totalPixels; NSLog(@"Mean: %.2f, Min: %.2f, Max: %.2f", mean, minVal, maxVal); // Adjust window/level [dcmPix changeWLWW:40 :400]; // WL=40, WW=400 for lung window // Convert pixel coordinates to DICOM coordinates float dicomCoords[3]; [dcmPix convertPixX:100 pixY:200 toDICOMCoords:dicomCoords]; NSLog(@"DICOM coords: (%.2f, %.2f, %.2f)", dicomCoords[0], dicomCoords[1], dicomCoords[2]); ``` -------------------------------- ### JavaScript Form and Study Management Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/admin/user.html Handles user interface interactions for managing studies in a form. It includes functions to save current study selections, revert to saved selections, confirm deletions, and adjust form elements based on user input. Dependencies include the browser's DOM API. ```javascript var savedStudies; function onload() { var form = document.getElementById('userEditionForm'); savedStudies = new Array(); var i; for (i = 0; i < form.studies.options.length; ++i) { var o = form.studies.options[i]; savedStudies.push(new Array(o.value, o.text)); } } function revertToSaved(form) { while (form.studies.options.length) form.studies.remove(0); var i; for (i = 0; i < savedStudies.length; ++i) { var o = savedStudies[i]; var option = document.createElement("option"); option.value = o[0]; option.text = o[1]; try { form.studies.add(option, null); // standards compliant; doesn't work in IE } catch(ex) { form.studies.add(option); // IE only } } return true; } window.onload = onload; function confirmDelete() { return confirm("Do you really want to delete the user named \"%X:EditedUser.name%\"?"); } function daysInMonth(year, month) { return new Date(year, month + 1, 0).getDate(); } function adjustForm(sel) { var form = sel; if (sel.form) form = sel.form; if (sel == form || sel.name == "autoDelete") form.deletionDate_year.disabled = form.deletionDate_month.disabled = form.deletionDate_day.disabled = !form.autoDelete.checked; if (sel == form || sel.name == "downloadZIP") form.encryptedZIP.disabled = !form.downloadZIP.checked; if (sel == form || sel.name == "uploadDICOM") form.uploadDICOMAddToSpecificStudies.disabled = !form.uploadDICOM.checked; if (sel == form || sel.name == "sendDICOMtoSelfIP") { form.sendDICOMtoAnyNodes.disabled = !form.sendDICOMtoSelfIP.checked; if (!form.sendDICOMtoSelfIP.checked) form.sendDICOMtoAnyNodes.checked = false; } } function adjustDates(sel) { var form = sel.form; var prefix = sel.name.substring(0, sel.name.lastIndexOf("_") + 1); var days = form[prefix + "day"]; var months = form[prefix + "month"]; var years = form[prefix + "year"]; var month = parseInt(months.value); var year = parseInt(years.value); var n = daysInMonth(year, month); // if selected day won't be available select the nearest day if (days.selectedIndex >= n) days.selectedIndex = n - 1; // remove/add days while (days.length > n) days.remove(days.length - 1); while (days.length < n) { var option = document.createElement("option"); option.text = option.value = days.length + 1; try { days.add(option, null); // standards compliant; doesn't work in IE } catch(ex) { days.add(option); // IE only } } } function selectedStudiesChanged(form) { var selCount = 0; var i; for (i = 0; i < form.studies.options.length; ++i) if (form.studies.options[i].selected) ++selCount; form.removeSelectedStudiesButton.disabled = selCount == 0; } function removeSelectedStudies(form) { while (form.studies.selectedIndex != -1) form.studies.remove(form.studies.selectedIndex); } function clear_password() { form.newPassword.value = ""; form.newPassword2.value = ""; } function willSubmit(form) { form.remainingStudies.value = ""; var i; for (i = 0; i < form.studies.options.length; ++i) form.remainingStudies.value += (form.remainingStudies.value.length ? "," : "") + escape(form.studies.options[i].value); setTimeout('clear_password()', 200); return true; } ``` -------------------------------- ### Reading DICOM Files Source: https://context7.com/bettar/miele-lxiv/llms.txt This section details how to use the DCMObject class to read and parse DICOM files, including accessing pixel data and DICOM attributes. ```APIDOC ## Reading DICOM Files ### Description This endpoint group allows for reading and parsing DICOM files using the `DCMObject` class. It supports various transfer syntaxes and compression formats. ### Method `[Objective-C]` ### Endpoint N/A (Class method) ### Parameters #### Path Parameters - **path** (NSString) - Required - The file path to the DICOM file. #### Query Parameters N/A #### Request Body N/A ### Request Example ```objective-c // Read a DICOM file with pixel data NSString *path = @"/path/to/dicom/file.dcm"; DCMObject *dcmObject = [DCMObject objectWithContentsOfFile:path decodingPixelData:YES]; // Access DICOM attributes by tag DCMAttributeTag *nameTag = [DCMAttributeTag tagWithName:@"PatientsName"]; DCMAttribute *nameAttr = [dcmObject attributeForTag:nameTag]; NSString *patientName = [[nameAttr values] objectAtIndex:0]; // Access attributes by name directly NSString *studyDesc = [dcmObject attributeValueWithName:@"StudyDescription"]; NSString *studyUID = [dcmObject attributeValueWithName:@"StudyInstanceUID"]; // Access pixel data DCMPixelDataAttribute *pixelData = [dcmObject attributeForTag: [DCMAttributeTag tagWithName:@"PixelData"]]; NSLog(@"Dimensions: %d x %d", [pixelData rows], [pixelData columns]); ``` ### Response #### Success Response (200) - **dcmObject** (DCMObject) - An instance of DCMObject representing the parsed DICOM file. - **patientName** (NSString) - The patient's name. - **studyDesc** (NSString) - The study description. - **studyUID** (NSString) - The study instance UID. - **pixelData** (DCMPixelDataAttribute) - The pixel data attribute, containing rows and columns. #### Response Example (Objective-C console output) ``` Dimensions: 512 x 512 ``` ``` -------------------------------- ### DICOM Send (C-STORE SCU) Source: https://context7.com/bettar/miele-lxiv/llms.txt This section describes how to send DICOM files to a remote PACS server or workstation using the C-STORE service class. ```APIDOC ## DICOM Send (C-STORE SCU) ### Description This endpoint group facilitates sending DICOM files to a remote PACS server or workstation using the C-STORE service class (SCU role). ### Method `[Objective-C]` ### Endpoint N/A (Class method) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A (Parameters are passed as a dictionary) ### Request Example ```objective-c // Prepare file list NSArray *filesToSend = @[@"/path/to/file1.dcm", @"/path/to/file2.dcm", @"/path/to/file3.dcm"]; // Configure connection parameters NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:@"MIELE_LXIV" forKey:@"callingAET"]; [params setObject:@"REMOTE_PACS" forKey:@"calledAET"]; [params setObject:@"192.168.1.100" forKey:@"hostname"]; [params setObject:@"11112" forKey:@"port"]; [params setObject:[DCMTransferSyntax ExplicitVRLittleEndianTransferSyntax] forKey:@"transferSyntax"]; [params setObject:filesToSend forKey:@"filesToSend"]; [params setObject:[NSNumber numberWithInt:1] forKey:@"debugLevel"]; // Send files BOOL result = [DCMStoreSCU sendWithParameters:params]; if (result) { NSLog(@"Successfully sent %lu files", (unsigned long)[filesToSend count]); } else { NSLog(@"Failed to send files"); } ``` ### Response #### Success Response (200) - **result** (BOOL) - Returns `YES` if the files were sent successfully, `NO` otherwise. #### Response Example (Objective-C console output) ``` Successfully sent 3 files ``` (Or) ``` Failed to send files ``` ``` -------------------------------- ### Read DICOM Files with DCMObject Source: https://context7.com/bettar/miele-lxiv/llms.txt Demonstrates reading DICOM files using the DCMObject class. It covers accessing file content, decoding pixel data, retrieving attributes by tag or name, and accessing pixel data properties. This functionality is crucial for any DICOM data processing. ```objective-c // Read a DICOM file with pixel data NSString *path = @"/path/to/dicom/file.dcm"; DCMObject *dcmObject = [DCMObject objectWithContentsOfFile:path decodingPixelData:YES]; // Access DICOM attributes by tag DCMAttributeTag *nameTag = [DCMAttributeTag tagWithName:@"PatientsName"]; DCMAttribute *nameAttr = [dcmObject attributeForTag:nameTag]; NSString *patientName = [[nameAttr values] objectAtIndex:0]; // Access attributes by name directly NSString *studyDesc = [dcmObject attributeValueWithName:@"StudyDescription"]; NSString *studyUID = [dcmObject attributeValueWithName:@"StudyInstanceUID"]; // Access pixel data DCMPixelDataAttribute *pixelData = [dcmObject attributeForTag: [DCMAttributeTag tagWithName:@"PixelData"]]; NSLog(@"Dimensions: %d x %d", [pixelData rows], [pixelData columns]); ``` -------------------------------- ### JavaScript Share Destination Change Handler Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/study.html This function `shareDestinationChange` controls the visibility of an element with the ID 'shareDestinationCreateTemp'. It toggles the display style of this element based on the selected value of a dropdown menu, showing it only when the selected value is 'NEW'. ```javascript function shareDestinationChange(select) { document.getElementById('shareDestinationCreateTemp').style.display = select.options[select.selectedIndex].value == 'NEW'? 'inline' : 'none'; } ``` -------------------------------- ### DICOM C-MOVE Retrieve Studies using Objective-C Source: https://context7.com/bettar/miele-lxiv/llms.txt This snippet illustrates how to initiate a DICOM C-MOVE operation to retrieve a specific study from a remote PACS server. It involves creating a move request object specifying the Study Instance UID and Query/Retrieve Level, along with connection parameters and the destination AET for the retrieved files. The operation returns a boolean indicating success. ```objective-c // Create move request for specific study DCMObject *moveObject = [DCMObject dcmObject]; [moveObject setAttributeValues:[NSMutableArray arrayWithObject: "1.2.840.113619.2.55.3.12345678.987"] forKey:@"StudyInstanceUID"]; [moveObject setAttributeValues:[NSMutableArray arrayWithObject:@"STUDY"] forKey:@"Query/RetrieveLevel"]; // Configure connection and move destination NSMutableDictionary *params = [NSMutableDictionary dictionary]; [params setObject:@"MIELE_LXIV" forKey:@"callingAET"]; [params setObject:@"REMOTE_PACS" forKey:@"calledAET"]; [params setObject:@"192.168.1.100" forKey:@"hostname"]; [params setObject:@"11112" forKey:@"port"]; [params setObject:@"MIELE_LXIV" forKey:@"moveDestination"]; [params setObject:moveObject forKey:@"moveObject"]; [params setObject:[DCMAbstractSyntaxUID studyRootQueryRetrieveInformationModelMove] forKey:@"affectedSOPClassUID"]; [params setObject:[DCMTransferSyntax ExplicitVRLittleEndianTransferSyntax] forKey:@"transferSyntax"]; // Execute move - PACS will send files to moveDestination AET BOOL success = [DCMMoveSCU moveWithParameters:params]; if (success) { NSLog(@"Move request completed successfully"); } ``` -------------------------------- ### JavaScript Form Checkbox Control Functions Source: https://github.com/bettar/miele-lxiv/blob/lxiv/Binaries/WebServicesHTML/English/study.html Contains JavaScript functions to control checkboxes within a form. `checkAll` and `uncheckAll` toggle the state of all checkboxes, while `checkboxChanged` updates the enabled/disabled state of 'CheckAll' and 'UncheckAll' buttons based on the selection status. It also manages the state of elements with the class 'if_selection'. ```javascript function checkAll(form) { for (var i = 0; i < form.selected.length; i++) form.selected[i].checked = true; checkboxChanged(form); } function uncheckAll(form) { for (var i = 0; i < form.selected.length; i++) form.selected[i].checked = false; checkboxChanged(form); } function checkboxChanged(form) { var allChecked = true; var allUnchecked = true; if( form.selected) { for (var i = 0; i < form.selected.length; i++) { if (allChecked && !form.selected[i].checked) allChecked = false; if (allUnchecked && form.selected[i].checked) allUnchecked = false; } } if( form.CheckAll) form.CheckAll.disabled = allChecked; if( form.UncheckAll) form.UncheckAll.disabled = allUnchecked; var ifs = form.getElementsByClassName('if_selection'); for (var i = 0; i < ifs.length; ++i) { ifs[i].disabled = allUnchecked; if (ifs[i].classList) { if (ifs[i].disabled && !ifs[i].classList.contains('disabled')) ifs[i].classList.add('disabled'); if (!ifs[i].disabled && ifs[i].classList.contains('disabled')) ifs[i].classList.remove('disabled'); } } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.