Analyzing a Case
This guide walks you through running a complete case analysis using StartAnalysis. This convenience function handles the entire workflow: uploading evidence, running crash analysis, biomechanics analysis, and computing case analytics.
How It Works
StartAnalysis is a convenience function that orchestrates the entire workflow. You provide image bytes and case data; the SDK handles everything else:
| Step | What the SDK Does Automatically |
|---|---|
| 1 | Creates a case (or uses existing caseId if provided) |
| 2 | Uploads your images and EDR files to the API |
| 3 | Runs crash analysis (Delta-V, PDOF calculations) |
| 4 | Runs biomechanics analysis (if occupants provided) |
| 5 | Computes case analytics with scores and insights |
What You Get
- Crash Analysis - Delta-V calculations, PDOF analysis, damage assessment
- Biomechanics Analysis - Injury mechanism analysis for each occupant (if provided)
- Case Analytics - Overall score, strengths, weaknesses, recommendations
Field Requirements
| Field | Required | Description |
|---|---|---|
organizationId | Yes | Organization to associate the case with |
plaintiff.images | Yes | Vehicle damage photos (JPEG/PNG) |
plaintiff.vehicleMake/Model/Year | Recommended | Improves analysis accuracy |
defendant.images | No | Defendant vehicle photos |
defendant.vehicleInfo | No | Defendant vehicle details |
occupants | No | Include for biomechanics analysis |
accidentDescription | No | Context for the analysis |
accidentDate | No | Date of accident (YYYY-MM-DD) |
edrFile | No | EDR data file |
Reusing Case Data
Already have a case from a previous analysis? See Running Additional Analyses to learn how to run multiple analysis types on the same case without re-uploading data.
Step 1: Set Up the Client
Initialize the SDK with your API key:
- Go
- TypeScript
package main
import (
"context"
"fmt"
"log"
"os"
"time"
silentwitness "github.com/silentwitness/go-sdk"
)
func main() {
silentwitness.Key = "sk-your-api-key"
ctx := context.Background()
// ... continue with analysis
}
import { SilentWitnessClient, startAnalysis } from "@silentwitness/typescript-sdk";
import fs from "fs";
const client = new SilentWitnessClient({ apiKey: "sk-your-api-key" });
Step 2: Load Your Evidence
Read the vehicle damage photos into memory. StartAnalysis will upload them automatically when you call it in Step 4.
- Go
- TypeScript
// Load plaintiff vehicle images
plaintiffFront, err := os.ReadFile("plaintiff-front.jpg")
if err != nil {
log.Fatal("Failed to load image:", err)
}
plaintiffRear, err := os.ReadFile("plaintiff-rear.jpg")
if err != nil {
log.Fatal("Failed to load image:", err)
}
// Optionally load defendant images
defendantFront, _ := os.ReadFile("defendant-front.jpg")
// Load plaintiff vehicle images
const plaintiffFront = fs.readFileSync("plaintiff-front.jpg");
const plaintiffRear = fs.readFileSync("plaintiff-rear.jpg");
// Optionally load defendant images
const defendantFront = fs.readFileSync("defendant-front.jpg");
- Include multiple angles: front, rear, sides, and close-ups of damage
- Higher resolution images produce better analysis
- 4-8 images per vehicle is ideal
Unlike the low-level SDK approach, you don't need to call Files.Upload() separately. Just pass the raw image bytes to StartAnalysis and it handles uploading, case creation, and analysis orchestration for you.
Step 3: Build the Request
Configure the analysis with your case data.
Basic Analysis (Crash Only)
- Go
- TypeScript
request := &silentwitness.AnalyzeCaseRequest{
OrganizationID: silentwitness.String("org_abc123"),
CaseName: silentwitness.String("Smith v. Jones"),
Plaintiff: &silentwitness.VehicleAnalysisData{
Images: [][]byte{plaintiffFront, plaintiffRear},
VehicleMake: silentwitness.String("Toyota"),
VehicleModel: silentwitness.String("Camry"),
VehicleYear: silentwitness.String("2020"),
},
AccidentDescription: silentwitness.String("Rear-end collision at red light"),
}
const request = {
organizationId: "org_abc123",
caseName: "Smith v. Jones",
plaintiff: {
images: [new Uint8Array(plaintiffFront), new Uint8Array(plaintiffRear)],
vehicleMake: "Toyota",
vehicleModel: "Camry",
vehicleYear: "2020",
},
accidentDescription: "Rear-end collision at red light",
};
Full Analysis (Crash + Biomechanics)
Add occupants to include biomechanics analysis:
- Go
- TypeScript
request := &silentwitness.AnalyzeCaseRequest{
OrganizationID: silentwitness.String("org_abc123"),
CaseName: silentwitness.String("Smith v. Jones"),
Plaintiff: &silentwitness.VehicleAnalysisData{
Images: [][]byte{plaintiffFront, plaintiffRear},
VehicleMake: silentwitness.String("Toyota"),
VehicleModel: silentwitness.String("Camry"),
VehicleYear: silentwitness.String("2020"),
},
// Add occupants for biomechanics analysis
Occupants: []silentwitness.OccupantAnalysisData{
{
Name: silentwitness.String("John Smith"),
Age: 45,
Gender: "male",
Position: "driver",
AllegedInjuries: []string{
"cervical_spine",
"lumbar_spine",
},
},
},
}
const request = {
organizationId: "org_abc123",
caseName: "Smith v. Jones",
plaintiff: {
images: [new Uint8Array(plaintiffFront), new Uint8Array(plaintiffRear)],
vehicleMake: "Toyota",
vehicleModel: "Camry",
vehicleYear: "2020",
},
// Add occupants for biomechanics analysis
occupants: [
{
name: "John Smith",
age: 45,
gender: "male",
position: "driver",
allegedInjuries: ["cervical_spine", "lumbar_spine"],
},
],
};
Occupant Field Values
When including occupants, use these values:
Positions: driver, front_passenger, rear_left, rear_center, rear_right
Injury types: head_brain, cervical_spine, thoracic_spine, lumbar_spine, shoulder, hip, knee, foot_ankle
Step 4: Run the Analysis
Start the analysis and wait for results:
- Go
- TypeScript
// Start the analysis
poller, err := silentwitness.StartAnalysis(ctx, request)
if err != nil {
log.Fatal("Failed to start analysis:", err)
}
// Wait for completion (2-5 minutes)
fmt.Println("Analysis started...")
for !poller.Done() {
fmt.Printf(" Status: %s\n", poller.StatusMessage())
time.Sleep(5 * time.Second)
}
// Get result
result, err := poller.Result()
if err != nil {
log.Fatal("Analysis failed:", err)
}
// Start the analysis
const poller = startAnalysis(client, request);
// Wait for completion (2-5 minutes)
console.log("Analysis started...");
while (!poller.isDone()) {
console.log(` Status: ${poller.getStatusMessage()}`);
await new Promise(r => setTimeout(r, 5000));
}
// Get result
const error = poller.getError();
if (error) {
throw error;
}
const result = await poller.wait();
Step 5: Interpret the Results
The result contains your case analytics and generated reports:
- Go
- TypeScript
// Overall case strength
fmt.Printf("\n=== Case Analysis Results ===\n")
fmt.Printf("Case ID: %s\n", result.CaseID)
fmt.Printf("Overall Score: %d/100\n", result.Analytics.OverallScore)
fmt.Printf("Category: %s\n", result.Analytics.Category)
// Individual metrics
fmt.Printf("\nMetrics:\n")
for _, metric := range result.Analytics.Metrics {
fmt.Printf(" - %s: %d/100\n", metric.Label, metric.Value)
}
// Strengths and weaknesses
fmt.Printf("\nStrengths:\n")
for _, s := range result.Analytics.Strengths {
fmt.Printf(" + %s\n", s)
}
fmt.Printf("\nWeaknesses:\n")
for _, w := range result.Analytics.Weaknesses {
fmt.Printf(" - %s\n", w)
}
// Recommendations
fmt.Printf("\nRecommendations:\n")
for _, r := range result.Analytics.Recommendations {
fmt.Printf(" > %s\n", r)
}
// Overall case strength
console.log("\n=== Case Analysis Results ===");
console.log(`Case ID: ${result.caseId}`);
console.log(`Overall Score: ${result.analytics.overallScore}/100`);
console.log(`Category: ${result.analytics.category}`);
// Individual metrics
console.log("\nMetrics:");
for (const metric of result.analytics.metrics) {
console.log(` - ${metric.label}: ${metric.value}/100`);
}
// Strengths and weaknesses
console.log("\nStrengths:");
for (const s of result.analytics.strengths) {
console.log(` + ${s}`);
}
console.log("\nWeaknesses:");
for (const w of result.analytics.weaknesses) {
console.log(` - ${w}`);
}
// Recommendations
console.log("\nRecommendations:");
for (const r of result.analytics.recommendations) {
console.log(` > ${r}`);
}
Example Output
- Formatted
- JSON
=== Case Analysis Results ===
Case ID: case_abc123xyz
Overall Score: 78/100
Category: Strong Case
Metrics:
- Liability Strength: 85/100
- Evidence Quality: 72/100
- Injury Correlation: 80/100
- Damages Potential: 75/100
Strengths:
+ Clear rear-end collision with established liability
+ Impact severity supports reported injury severity
+ Injury mechanisms are consistent with crash dynamics
Weaknesses:
- Pre-existing cervical condition noted in medical records
- EDR data not available for precise speed analysis
Recommendations:
> Obtain treating physician declaration linking crash to symptoms
> Request defendant's EDR data through discovery
{
"caseId": "case_abc123xyz",
"analytics": {
"overallScore": 78,
"category": "Strong Case",
"metrics": [
{ "label": "Liability Strength", "value": 85 },
{ "label": "Evidence Quality", "value": 72 },
{ "label": "Injury Correlation", "value": 80 },
{ "label": "Damages Potential", "value": 75 }
],
"strengths": [
"Clear rear-end collision with established liability",
"Impact severity supports reported injury severity",
"Injury mechanisms are consistent with crash dynamics"
],
"weaknesses": [
"Pre-existing cervical condition noted in medical records",
"EDR data not available for precise speed analysis"
],
"recommendations": [
"Obtain treating physician declaration linking crash to symptoms",
"Request defendant's EDR data through discovery"
]
}
}
Understanding the Score Categories
| Score | Category | Meaning |
|---|---|---|
| 80-100 | Strong Case | High likelihood of favorable outcome |
| 60-79 | Moderate Case | Good case with some areas to address |
| 40-59 | Challenging Case | Significant weaknesses to overcome |
| 0-39 | Weak Case | Major obstacles to success |
Complete Code Example
Here's the full code putting it all together:
- Go
- TypeScript
package main
import (
"context"
"fmt"
"log"
"os"
"time"
silentwitness "github.com/silentwitness/go-sdk"
)
func main() {
// Initialize
silentwitness.Key = "sk-your-api-key"
ctx := context.Background()
// Load images
plaintiffFront, _ := os.ReadFile("plaintiff-front.jpg")
plaintiffRear, _ := os.ReadFile("plaintiff-rear.jpg")
// Build request
request := &silentwitness.AnalyzeCaseRequest{
OrganizationID: silentwitness.String("org_abc123"),
CaseName: silentwitness.String("Smith v. Jones"),
Plaintiff: &silentwitness.VehicleAnalysisData{
Images: [][]byte{plaintiffFront, plaintiffRear},
VehicleMake: silentwitness.String("Toyota"),
VehicleModel: silentwitness.String("Camry"),
VehicleYear: silentwitness.String("2020"),
},
Occupants: []silentwitness.OccupantAnalysisData{
{
Age: 45,
Gender: "male",
Position: "driver",
AllegedInjuries: []string{"cervical_spine", "lumbar_spine"},
},
},
}
// Run analysis
poller, err := silentwitness.StartAnalysis(ctx, request)
if err != nil {
log.Fatal(err)
}
// Wait for completion
for !poller.Done() {
fmt.Printf("Status: %s\n", poller.StatusMessage())
time.Sleep(5 * time.Second)
}
result, err := poller.Result()
if err != nil {
log.Fatal(err)
}
// Display results
fmt.Printf("\nScore: %d/100 (%s)\n", result.Analytics.OverallScore, result.Analytics.Category)
}
import { SilentWitnessClient, startAnalysis } from "@silentwitness/typescript-sdk";
import fs from "fs";
async function main() {
// Initialize
const client = new SilentWitnessClient({ apiKey: "sk-your-api-key" });
// Load images
const plaintiffFront = fs.readFileSync("plaintiff-front.jpg");
const plaintiffRear = fs.readFileSync("plaintiff-rear.jpg");
// Build request
const request = {
organizationId: "org_abc123",
caseName: "Smith v. Jones",
plaintiff: {
images: [new Uint8Array(plaintiffFront), new Uint8Array(plaintiffRear)],
vehicleMake: "Toyota",
vehicleModel: "Camry",
vehicleYear: "2020",
},
occupants: [
{
age: 45,
gender: "male",
position: "driver",
allegedInjuries: ["cervical_spine", "lumbar_spine"],
},
],
};
// Run analysis
const poller = startAnalysis(client, request);
// Wait for completion
while (!poller.isDone()) {
console.log(`Status: ${poller.getStatusMessage()}`);
await new Promise(r => setTimeout(r, 5000));
}
const result = await poller.wait();
// Display results
console.log(`\nScore: ${result.analytics.overallScore}/100 (${result.analytics.category})`);
}
main().catch(console.error);
Next Steps
- Running Additional Analyses - Run multiple analysis types on the same case
- StartAnalysis Reference - Full API documentation
- Generating a Report - Create PDF technical reports