CarbonInterval {#1680 ▼
interval: + 00:07:36.0
#tzName: null
#localMonthsOverflow: null
#localYearsOverflow: null
#localStrictModeEnabled: null
#localHumanDiffOptions: null
#localToStringFormat: null
#localSerializer: null
#localMacros: null
#localGenericMacros: null
#localFormatFunction: null
#localTranslator: null
+"y": 0
+"m": 0
+"d": 0
+"h": 0
+"i": 0
+"s": 456
+"f": 0.0
+"weekday": 0
+"weekday_behavior": 0
+"first_last_day_of": 0
+"invert": 0
+"days": false
+"special_type": 0
+"special_amount": 0
+"have_weekday_relative": 0
+"have_special_relative": 0
}
How can I access this interval: + 00:07:36.0 value form this CarbonPeriod object.
CarbonInterval has a function called cascade() which will fill out the other fields accordingly.
Which will return carbonInterval object something like this.
+"y": 0
+"m": 0
+"d": 0
+"h": 0
+"i": 7
+"s": 36
+"f": 0.0
Then we can access those properties or we can call format('%H:%I:%s') to get the desired value.
Example
$carbonInterval->cascade()->format('%H:%I:%s')
Related
Is there a way to pass a static variable to a GraphQL endpoint in order to be returned with the response?
In my case I'm pulling timesheets for a specific userId. Unfortunately the userId isn't returned in the response.
Types
type Query {
# Returns a timesheet for user id and given date.
#
# Arguments
# userId: User's id.
# date: Date.
timesheet(userId: ID, date: Date!): Timesheet
}
type Timesheet {
# Id.
id: ID
# Date.
date: Date
# Expected time based on work schedule in seconds.
expectedTime: Int
# Tracked time in seconds.
trackedTime: Int
# Time off time in seconds.
timeOffTime: Int
# Holiday time in seconds.
holidayTime: Int
# Sum of tracked, holiday, time off time minus break time.
totalTime: Int
# Break time in seconds.
breakTime: Int
}
Request Body
{"query":"{
timesheets(userId: \"10608\", dateFrom: \"2022-01-01\", dateTo: \"2022-12-31\") {
items { id date trackedTime timeOffTime holidayTime totalTime breakTime }
}
}"}
Example Response
data.timesheets.items.id
data.timesheets.items.date
data.timesheets.items.trackedTime
data.timesheets.items.timeOffTime
data.timesheets.items.holidayTime
data.timesheets.items.totalTime
data.timesheets.items.breakTime
3646982
2022-01-01
0
0
0
0
3495676
2022-01-02
18000
0
0
18000
3500068
2022-01-03
35100
0
0
35100
Desired Response
userId
data.timesheets.items.id
data.timesheets.items.date
data.timesheets.items.trackedTime
data.timesheets.items.timeOffTime
data.timesheets.items.holidayTime
data.timesheets.items.totalTime
data.timesheets.items.breakTime
10608
3646982
2022-01-01
0
0
0
0
10608
3495676
2022-01-02
18000
0
0
18000
10608
3500068
2022-01-03
35100
0
0
35100
I tried this first: GET _cat/indices which gave me all of my indices.
I added GET _cat/indices?v to get the column names so I would be able to sort by column name like this GET _cat/indices?v&s=store.size
Now, I just want to swap the sort order.
ElasticSearch guide had no information regarding this.
You can use the suffix :desc like this to get there:
http://localhost:9200/_cat/indices/?s=store.size:desc
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open tmdb DVLEul7bT4yGyiq34h4nCQ 1 1 27760 0 119.8mb 119.8mb
green open .kibana_2 6WJ3UFpOSj2O8zi-iLuw6w 1 0 10 0 35.3kb 35.3kb
green open .kibana_task_manager_1 WSwYXmMOSpyQOQ8ZIRniwg 1 0 2 0 31.6kb 31.6kb
green open .tasks _SsI5VWNSwO5Yfps3K12Qg 1 0 1 0 6.3kb 6.3kb
green open .kibana_1 MukHGTHfTkKS1HcYodfNqA 1 0 1 0 4kb 4kb
yellow open my_index 7FgIWDJOSQesKbJI-HKRoA 1 1 1 0 3.8kb 3.8kb
green open .ltrstore -Xh6WnJYSsWIoPGP8fhgGw 1 0 0 0 283b 283b
green open .apm-agent-configuration 6FUF8T5oTDGcLBqcU7ymJg 1 0 0 0 283b 283b
This ability is mildly-buried/described-briefly in this section of the docs.
I want to get difference between two times in hour:min:sec format. For Example starting time 02:00:00 and ending time 02:30:00 Difference should be 00:30:00
I tried to use Carbon but i think it support different format
<td> {{ \Carbon\Carbon::now()->diff(\Carbon\Carbon::parse($sales->created_at))}}</td>
I want to get difference in hour:min:sec input would also be in same format
Your code is working fine,
$diff = \Carbon\Carbon::now()->diff(\Carbon\Carbon::parse('12:50:35'));
This will return DateInterval object,
DateInterval {#242 ▼
interval: + 11:18:14.006875
+"y": 0
+"m": 0
+"d": 0
+"h": 11
+"i": 18
+"s": 14
+"f": 0.006875
+"weekday": 0
+"weekday_behavior": 0
+"first_last_day_of": 0
+"invert": 0
+"days": 0
+"special_type": 0
+"special_amount": 0
+"have_weekday_relative": 0
+"have_special_relative": 0
}
Then you can get diff in hours, seconds, minutes, days etc.
$diff->h, $diff->i, $diff->s, $diff->days
So your input would be,
$diff->h .':'. $diff->i .':'. $diff->s
Otherwise you can use,
$diffInhours = \Carbon\Carbon::now()->diffInHours(\Carbon\Carbon::parse('12:50:35');
$diffInMinutes = \Carbon\Carbon::now()->diffInMinutes(\Carbon\Carbon::parse('12:50:35'));
Or many other ways.
Carbon diff() function returns a DateInterval Object.
Your expected result can be retrieve from DateInterval object by calling format() function.
<td>
{{ $timeDifference = now()->diff($sales->created_at)->format('%h:%i:%s') }}
</td>
I'm new to processing DICOM images away from their native manufacturer software. I am trying to dicomread a PET image from a set of reconstructed transaxial slices into MatLab. My aim is to do some simple segmentation and finally determine the maximum and minimum pixel value in the segment. However I am having trouble with converting the stored values to their values seen on the native system.
The image is loading into MatLab as an int16 class. The maximum pixel value is always 32767, regardless of which slice I load from the series. I know from viewing the images on their native system that the maximum pixel value in each slice is different.
I've checked the rescale value and rescale intercept values and the rescale relationship appears to be linear. Is there another correction I should be making? I assume all other corrections (e.g. decay, scatter and randoms) are made during the reconstruction process.
Any help would be appreciated (hopefully I'm missing something simple!).I've posted the DICOM info retrieved from the header below (Don't worry, the images are of a phantom so there is no patient identifying data).
Regards,
Ross
Filename: [1x76 char]
FileModDate: '26-Jul-2013 10:50:42'
FileSize: 38356
Format: 'DICOM'
FormatVersion: 3
Width: 128
Height: 128
BitDepth: 16
ColorType: 'grayscale'
FileMetaInformationGroupLength: 182
FileMetaInformationVersion: [2x1 uint8]
MediaStorageSOPClassUID: '1.2.840.10008.5.1.4.1.1.128'
MediaStorageSOPInstanceUID: [1x49 char]
TransferSyntaxUID: '1.2.840.10008.1.2.1'
ImplementationClassUID: '1.2.840.113619.6.55'
SourceApplicationEntityTitle: 'dst01'
IdentifyingGroupLength: 484
SpecificCharacterSet: 'ISO_IR 100'
ImageType: 'ORIGINAL\PRIMARY'
InstanceCreationDate: '20130522'
InstanceCreationTime: '171655'
InstanceCreatorUID: '1.2.840.113619.1.131'
SOPClassUID: '1.2.840.10008.5.1.4.1.1.128'
SOPInstanceUID: [1x49 char]
StudyDate: '20130514'
SeriesDate: '20130514'
AcquisitionDate: '20130514'
ContentDate: '20130522'
StudyTime: '142911'
SeriesTime: '143208.00'
AcquisitionTime: '143208.00'
ContentTime: '171655'
AccessionNumber: ''
Modality: 'PT'
Manufacturer: 'GE MEDICAL SYSTEMS'
InstitutionName: 'NHS TRUST'
ReferringPhysicianName: [1x1 struct]
StationName: 'dst01'
StudyDescription: ''
SeriesDescription: 'WB_3D_VuePoint'
PhysicianReadingStudy: [1x1 struct]
OperatorName: [1x1 struct]
ManufacturerModelName: 'Discovery STE'
Private_0009_GroupLength: 2714
Private_0009_10xx_Creator: 'GEMS_PETD_01'
Private_0009_11xx_Creator: 'GEMS_GENIE_1'
Private_0009_1002: 'SOLID_TEST'
Private_0009_1005: '20130514143030.00'
Private_0009_1006: 0
Private_0009_100a: [1x45 char]
Private_0009_100d: '20130514143208.00'
Private_0009_100e: '20130514143055.00'
Private_0009_1013: [1x59 char]
Private_0009_1014: 'Sternal Notch'
Private_0009_1015: 'SN'
Private_0009_1016: 0
Private_0009_1017: 0
Private_0009_1018: 0
Private_0009_1019: 0
Private_0009_101a: 1
Private_0009_101b: 0
Private_0009_101c: 1
Private_0009_101d: 0
Private_0009_101e: 1
Private_0009_101f: 1
Private_0009_1020: 0
Private_0009_1021: 1
Private_0009_1022: 0
Private_0009_1023: 0
Private_0009_1024: 2
Private_0009_1025: 2
Private_0009_1026: 23
Private_0009_1027: 1
Private_0009_1028: 1
Private_0009_1029: 0
Private_0009_102a: 0
Private_0009_102b: 70
Private_0009_102c: 153
Private_0009_102d: 0
Private_0009_102e: 0
Private_0009_1034: 0
Private_0009_1035: 0
Private_0009_1036: 'FDG -- fluorodeoxyglucose'
Private_0009_1037: ''
Private_0009_1038: 0
Private_0009_1039: ''
Private_0009_103a: 0
Private_0009_103b: ''
Private_0009_103c: 0
Private_0009_103d: ''
Private_0009_103e: '18F'
Private_0009_103f: 6588
Private_0009_1040: 0.9700
Private_0009_104d: 0
Private_0009_104e: 23
Private_0009_104f: 23
Private_0009_1050: 7
Private_0009_1051: 7
Private_0009_1052: 32
Private_0009_1053: 800
Private_0009_1054: 650
Private_0009_1055: 425
Private_0009_1056: [1x49 char]
Private_0009_1057: [1x48 char]
Private_0009_1059: [1x49 char]
Private_0009_105a: 0
Private_0009_105c: [1x49 char]
Private_0009_105d: [1x45 char]
Private_0009_105e: [1x51 char]
Private_0009_105f: 'SOLID_TEST'
Private_0009_1062: [1x44 char]
Private_0009_1063: 0
Private_0009_1064: 0
Private_0009_1066: 119.5000
Private_0009_1067: -79.8540
Private_0009_1068: '20130514143123.00'
Private_0009_1069: 553
Private_0009_106a: -79.9000
Private_0009_106b: 0
Private_0009_106c: '20130514143208.00'
Private_0009_106d: 180
Private_0009_1070: 0
Private_0009_1071: 90674329
Private_0009_1072: 0
Private_0009_1073: 1
Private_0009_1074: 255
Private_0009_107c: 0
Private_0009_107d: 2
Private_0009_107e: 0
Private_0009_107f: 0
Private_0009_1080: 0
Private_0009_1081: 0
Private_0009_108b: 5
Private_0009_108c: 2
Private_0009_108d: 0.0960
Private_0009_108e: 0
Private_0009_108f: 0
Private_0009_1090: 0
Private_0009_1091: 0
Private_0009_1092: 0
Private_0009_1093: 0
Private_0009_1094: 0
Private_0009_1095: 0
Private_0009_1096: [1x49 char]
Private_0009_1097: [1x51 char]
Private_0009_1098: [1x49 char]
Private_0009_1099: ''
Private_0009_109a: 0
Private_0009_109b: 0
Private_0009_109c: ''
Private_0009_109d: 0
Private_0009_109e: 0
Private_0009_109f: 0
Private_0009_10a0: 0
Private_0009_10a1: 0
Private_0009_10a2: 0
Private_0009_10a3: 0
Private_0009_10a6: 26
Private_0009_10a7: 0
Private_0009_10ab: 0
Private_0009_10ac: 0
Private_0009_10ad: ''
Private_0009_10ae: ''
Private_0009_10b2: 2
Private_0009_10b3: 20
Private_0009_10b4: 70
Private_0009_10b5: 0
Private_0009_10b6: 0
Private_0009_10b7: 0
Private_0009_10b8: 0
Private_0009_10b9: 0
Private_0009_10ba: 1
Private_0009_10bb: 6
Private_0009_10bc: 0
Private_0009_10bd: 0
Private_0009_10be: 0
Private_0009_10bf: 0
Private_0009_10c0: 0
Private_0009_10c1: 0
Private_0009_10c2: 0
Private_0009_10c3: 0
Private_0009_10c4: 6
Private_0009_10c5: 0
Private_0009_10c6: 0
Private_0009_10c7: 0
Private_0009_10cb: 0.8601
Private_0009_10cc: 0.1256
Private_0009_10cd: 0.8240
Private_0009_10ce: -0.0254
Private_0009_10cf: 0.5000
Private_0009_10d0: -0.0483
Private_0009_10d5: 0
Private_0009_10d6: 70.5000
Private_0009_10d7: -79.9000
Private_0009_10d8: 1
Private_0009_10db: 3
Private_0009_10dc: 2
Private_0009_10df: 47
Private_0009_10e2: 10
Private_0009_10e4: '3D_AC'
Private_0009_10e5: 0
Private_0009_10e6: 0
Private_0009_10e7: 0
Private_0009_10e9: 0
Private_0009_10ea: 0
Private_0009_10eb: 0
Private_0009_10ec: 0
Private_0009_111e: [1x49 char]
Private_0009_1146: [1x49 char]
PatientGroupLength: 96
PatientName: [1x1 struct]
PatientID: 'SOLID_TEST'
PatientBirthDate: ''
PatientSex: ''
PatientAge: ''
PatientSize: 0
PatientWeight: 0
EthnicGroup: ''
AdditionalPatientHistory: ''
Private_0017_GroupLength: 46
Private_0017_10xx_Creator: 'GEMS_PETD_01'
Private_0017_1004: '20130207140047.00'
AcquisitionGroupLength: 230
SliceThickness: 3.2700
AcquisitionTerminationCondition: 'TIME'
AcquisitionStartCondition: 'MANU'
AcquisitionStartConditionData: 0
AcquisitionTerminationConditionData: 0
SoftwareVersion: '41.04'
ProtocolName: 'WB 3D'
TriggerTime: 0
FrameTime: 0
IntervalsAcquired: 0
IntervalsRejected: 0
ReconstructionDiameter: 700
GantryDetectorTilt: 0
FieldOfViewShape: 'CYLINDRICAL RING'
FieldOfViewDimensions: [2x1 double]
CollimatorType: 'NONE'
ActualFrameDuration: 180000
PatientPosition: 'HFS'
Private_0019_GroupLength: 42
Private_0019_10xx_Creator: 'GEMS_PETD_01'
Private_0019_1004: '20130207140602'
RelationshipGroupLength: 322
StudyInstanceUID: [1x51 char]
SeriesInstanceUID: [1x49 char]
StudyID: '6893'
SeriesNumber: 401
InstanceNumber: 22
ImagePositionPatient: [3x1 double]
ImageOrientationPatient: [6x1 double]
FrameOfReferenceUID: [1x59 char]
PositionReferenceIndicator: 'SN'
SliceLocation: 1.8500
ImagePresentationGroupLength: 218
SamplesPerPixel: 1
PhotometricInterpretation: 'MONOCHROME2'
Rows: 128
Columns: 128
PixelSpacing: [2x1 double]
CorrectedImage: [1x40 char]
BitsAllocated: 16
BitsStored: 16
HighBit: 15
PixelRepresentation: 1
SmallestImagePixelValue: 0
LargestImagePixelValue: 32767
RescaleIntercept: 0
RescaleSlope: 0.3555
LossyImageCompression: '00'
Unknown_0040_0000: 158
AcquisitionContextSequence: [1x1 struct]
NuclearAcquisitionGroupLength: 808
EnergyWindowRangeSequence: [1x1 struct]
RadiopharmaceuticalInformationSequence: [1x1 struct]
NumberOfSlices: 47
TypeOfDetectorMotion: 'NONE'
PatientOrientationCodeSequence: [1x1 struct]
PatientOrientationModifierCodeSequence: [1x1 struct]
PatientGantryRelationshipCodeSequence: [1x1 struct]
SeriesType: 'STATIC\IMAGE'
Units: 'BQML'
CountsSource: 'EMISSION'
RandomsCorrectionMethod: 'SING'
AttenuationCorrectionMethod: 'measured,, 0.096000 cm-1,'
DecayCorrection: 'START'
ReconstructionMethod: '3D IR'
DetectorLinesOfResponseUsed: '0'
ScatterCorrectionMethod: 'Model Based'
AxialMash: [2x1 double]
TransverseMash: 2
CoincidenceWindowWidth: 0
FrameReferenceTime: 0
PrimaryPromptsCountsAccumulated: 0
SecondaryCountsAccumulated: 0
SliceSensitivityFactor: 1
DecayFactor: 1.0095
DoseCalibrationFactor: 1139
ScatterFractionFactor: 0.3174
DeadTimeFactor: 1.1243
ImageIndex: 26
PixelDataGroupLength: 32780
I work in mammo and have no experience of PET so take what I say here with a pinch of salt.
The maximum pixel value is 32767 which is 2 to the power of 15 minus 1. Is the rescale slope not of importance?
RescaleSlope: 0.3555
Presumably this can vary for each slice and the pixel values should be multiplied by this value (intercept should be added too but this is zero).
Out of the major scanner manufacturers (Siemens, GE, Philips) I have only encountered a slice-by-slice RescaleSlope value when working with GE PET cameras. However, it is always a good idea to check RescaleSlope and RescaleIntercept. The QIBA working group on FDG-PET has a collection of recommendations and also pseudocode for SUV calculations straight from the DICOM data.
I have a dataset that looks like this:
Date
Category
Rate
Quantity
There will be 0 or 1 row for each Category for any given Date.
What is a good way to get this data into a summary type of view?
For example:
Date
Category1_Rate
Category2_Rate
Category3_Rate
Category4_Rate
I have a fixed number of Categories.
I'm using linq.
Here is an example. If I have this data:
Date Category Rate Quantity
1/1/12 toys 15 12
1/1/12 games 20 20
1/1/12 dvds 18 30
1/2/12 toys 19 13
1/2/12 dvds 20 17
I want to produce a summary that looks like this:
Date toys_rate games_rate dvds_rate
1/1/12 15 20 18
1/2/12 19 null 20
Possibly something like this
var summarydata =
from r in table
group r by r.Date into g
select new
{
Date = g.Key,
ToysRate = g.Where(e=> e.Category == "toys").Count() > 0 ?
(int?)g.Where(e=> e.Category == "toys").First().Rate : null,
GamesRate = g.Where(e=> e.Category == "games").Count() > 0 ?
(int?)g.Where(e=> e.Category == "games").First().Rate : null,
DvdsRate = g.Where(e=> e.Category == "dvds").Count() > 0 ?
(int?)g.Where(e=> e.Category == "dvds").First().Rate : null
};
Note I haven't tested this as I don't current have access to a C# environment.
EDIT - Added nullable int casts to properly set the type of the various rate fields in the resulting anonymous type.